perm filename DVICH.TEX[MF,ALS] blob
sn#794966 filedate 1985-05-30 generic text, type T, neo UTF8
\input webmac
% This program by A. L. Samuel is not copyrighted and can be used freely.
% This program depends heavily on DVItype.WEB by D. E. Knuth for much of
% the basic material relating to the reading of DVI files and on GFtoDOVER
% for much of the basic material relating to the reading of GF files.
% The idea of getting the font information directly from the GF files
% rather than from PXL and TFM files was suggested by D. E. Knuth,
% Several people have contributed ideas as to fast methods of doing this.
% Version 0.3 now accepts as many as 50 256-character fonts and it does an
% automatic spooling job for the Imagen with the pages properly collated.
% Version 0.4 Corrections for the new_row_69 bug and a major clean-up by
% D.R.Fuchs with the introduction of |debug| and |gubed| instead of the
% earlier temporary fix.
% Version 0.5 Fix to get TFM widths for fonts with no GF file available.
% Version 0.6 Fix to handle |empty_glyph| cases properly, and a minor
% change to the |reconcile_scale| routine.
% Version 0.7 Major change to |m_store| now |m_mstore|, likg it to
% store from |[0,4] through |[0,85999]| then to |[1,4]| through |[1,85999]|.
% Version 0.8 Added switches /f, /n, and /c, being respectively, the number
% count[0] of the first page to be printed, the total number of pages and the
% number of copies desired
% Here is TeX material that gets inserted after \input webmac
\def\hang{\hangindent 3em\indent\ignorespaces}
\font\ninerm=amr9
\let\mc=\ninerm % medium caps for names like PASCAL
\def\PASCAL{{\mc PASCAL}}
\let\swap=\leftrightarrow
\font\logo=manfnt % font used for the METAFONT logo
\def\MF{{\logo META}\-{\logo FONT}}
\def\(#1){} % this is used to make section names sort themselves better
\def\9#1{} % this is used for sort keys in the index
\def\title{DVIIMP}
\def\contentspagenumber{401}
\def\topofcontents{\null
\def\titlepage{F} % include headline on the contents page
\def\rheader{\mainfont\hfil \contentspagenumber}
\vfill
\centerline{\titlefont The {\ttitlefont DVIIMP} processor}
\vskip 15pt
\centerline{(Version 0.8, April 1985)}
\vfill}
\def\botofcontents{\vfill
\centerline{(This listing shows the changes for {\sc WAITS} only)}}
\let\maybe=\iffalse
\pageno=\contentspagenumber \advance\pageno by 1
\N1. Introduction.
This \.{DVIIMP} program reads binary device-independent (``\.{DVI}'')
files that are produced by document compilers such as \TeX, and converts
them into a form acceptable to the \.{IMAGEN} printer. The primary use of
this program will be to print documents that use a large variety of
different fonts that are freshly prepared by the \MF\ program and with
this use in mind the program gets the needed font information directly
from \.{GF} files. This direct use of \.{GF} font information may set a
trend but it should be noted that many older but still useful fonts may
not be available in \.{GF} form. \.{DVIIMP} has been written in the
\.{WEB} language to conform with the general practice for other programs
of this general type and to simplify the task of adapting it for use on a
variety of different computers and different operating systems.
This program reads the \.{GF} files and stores the font information
(somewhat compressed and simplified from the
\.{GF} file format) in an array called \\{mm\_store},
and only translates the detailed raster
information into the needed \.{IMPRESS} format a glyph at a time on the first
occurance of each needed glyph in the document being translated. This
requires a rather involved procedure for keeping a record of those glyphs
that have already been transmitted and of providing for the possibilities
that the memory space allowed for fonts in the main memory associated with
this program and the internal memory within the \.{IMAGEN} for glyphs may
not be large enough for the job without arranging for the deletion of some
font information and its possible replacement should it again prove to be
needed.
There seems to be a 2-to-the-17th-pixel limit to the maximum permitted
size of glyph that IMAGEN will accept, measured as the product of the
glyph's width (rounded up to a whole number of bytes) and its height.
The \\{banner} string defined here should be changed whenever \.{DVIIMP}
gets modified.
\Y\P\D \37$\\{banner}\S\.{\'This\ is\ DVIIMP,\ Version\ 0.8\'}$\C{printed when
the program starts}\par
\P\D \37$\\{debug}\S\B$\C{change this to `$\\{debug}\equiv\null$' when
debugging}\par
\P\D \37$\\{gubed}\S\hbox{}\T$\C{change this to `$\\{gubed}\equiv\null$' when
debugging}\par
\P\F \37$\\{debug}\S\\{begin}$\par
\P\F \37$\\{gubed}\S\\{end}$\par
\fi
\M2. This program is written in standard \PASCAL, except where it is necessary
to use extensions; for example, \.{DVIIMP} must read files whose names
are dynamically specified, and that would be impossible in pure \PASCAL.
All places where nonstandard constructions are used have been listed in
the index under ``system dependencies.''
One of the extensions to standard \PASCAL\ that we shall deal with is the
ability to move to a random place in a binary file; another is to
determine the length of a binary file. If \.{DVIIMP} is being used
with \PASCAL s for which random file positioning is not efficiently
available, the following definition should be changed from \\{true} to
\\{false}; in such cases, \.{DVIIMP} will not include the optional feature
that reads the postamble first.
Another extension is to use a default \&{case} as in \.{TANGLE}, \.{WEAVE},
etc.
\Y\P\D \37$\\{random\_reading}\S\\{true}$\C{should we skip around in the file?}%
\par
\P\D \37$\\{othercases}\S\\{others}$: \37\C{default for cases not listed
explicitly}\par
\P\D \37$\\{endcases}\S$\ \&{end} \C{follows the default case in an extended %
\&{case} statement}\par
\P\F \37$\\{othercases}\S\\{else}$\par
\P\F \37$\\{endcases}\S\\{end}$\par
\fi
\M3\*. The binary input comes from \\{dvi\_file}, and the symbolic output is
written
on \PASCAL's standard \\{output} file. The term \\{print} is used instead of
\\{write} when this program writes on \\{output}, so that all such output
could easily be redirected if desired.
\Y\P\D \37$\\{print}(\#)\S\\{write}(\\{tty},\39\#)$\par
\P\D \37$\\{print\_ln}(\#)\S\\{write\_ln}(\\{tty},\39\#)$\par
\Y\P$\hbox{\4}\B\$\|D+,\39\|W+\T$\C{no debugging overhead}\6
\4\&{program}\1\ \37\\{DVI\_IMP};\6
\4\&{label} \37\X4:Labels in the outer block\X\6
\4\&{const} \37\X5:Constants in the outer block\X\6
\4\&{type} \37\X8:Types in the outer block\X\6
\4\&{var} \37\X10:Globals in the outer block\X\6
\\{tempo}: \37\\{integer};\6
\4\&{procedure}\1\ \37\\{initialize};\C{this procedure gets things started
properly}\6
\4\&{var} \37$\|i,\39\|j$: \37\\{integer};\C{loop indices for initializations}\6
\\{jj}: \37\\{real};\C{a real variable}\2\6
\&{begin} \37$\\{print\_ln}(\\{banner})$;\6
\X11:Set initial values\X\6
\&{end};\par
\fi
\M4. If the program has to stop prematurely, it goes to the
`\\{final\_end}'. Another label, \\{done}, is used when stopping normally.
\Y\P\D \37$\\{final\_end}=9999$\C{label for the end of it all}\par
\P\D \37$\\{done}=30$\C{go here when finished with a subtask}\par
\P\D \37$\\{restart}=40$\C{go here to restart an operation}\par
\Y\P$\4\X4:Labels in the outer block\X\S$\6
\\{final\_end};\par
\U section~3\*.\fi
\M5. The following parameters can be changed at compile time to extend or
reduce \.{DVIIMP}'s capacity.
\Y\P$\4\X5:Constants in the outer block\X\S$\6
$\\{max\_fonts}=50$;\C{maximum number of distinct fonts per \.{DVI} file}\6
$\\{max\_glyphs}=7680$;\C{maximum number of different characters among all
fonts}\6
$\\{line\_length}=320$;\C{bracketed lines of output will be at most this long}\6
$\\{terminal\_line\_length}=150$;\C{maximum number of characters input in a
single line of input from the terminal}\6
$\\{stack\_size}=100$;\C{\.{DVI} files shouldn't \\{push} beyond this depth}\6
$\\{name\_size}=1000$;\C{total length of all font file names}\6
$\\{name\_length}=50$;\C{a file name shouldn't be longer than this}\6
$\\{m1\_max}=3$;\C{max first \\{mm\_store} index}\6
$\\{m2\_size}=86000$;\C{used as multiplier or divider}\6
$\\{m2\_max}=85999$;\C{max second \\{mm\_store} index}\6
$\\{mm\_size}=344000$;\C{bytes in \\{mm\_store}}\6
$\\{mm\_max}=343999$;\C{max location in \\{mm\_store}}\6
$\\{max\_char\_no}=255$;\C{largest allowed char number}\par
\A section~153\*.
\U section~3\*.\fi
\M6. Here are some macros for common programming idioms. We will have occasion,
both in the \\{do\_page} and the \\{do\_char} routines, to group certain cases
together and so we will also define these groupings at this time.
\Y\P\D \37$\\{incr}(\#)\S\#\K\#+1$\C{increase a variable by unity}\par
\P\D \37$\\{decr}(\#)\S\#\K\#-1$\C{decrease a variable by unity}\par
\P\D \37$\\{do\_nothing}\S$\C{empty statement}\par
\P\D \37$\\{unity}\S\O{200000}$\C{$2↑{16}$, represents 1.00000}\par
\P\D \37$\\{three\_cases}(\#)\S\#,\39\#+1,\39\#+2$\par
\P\D \37$\\{four\_cases}(\#)\S\#,\39\#+1,\39\#+2,\39\#+3$\par
\P\D \37$\\{eight\_cases}(\#)\S\\{four\_cases}(\#),\39\\{four\_cases}(\#+4)$\par
\P\D \37$\\{nine\_cases}(\#)\S\\{eight\_cases}(\#),\39\#+8$\par
\P\D \37$\\{sixteen\_cases}(\#)\S\\{eight\_cases}(\#),\39\\{eight\_cases}(%
\#+8)$\par
\P\D \37$\\{nineteen\_cases}(\#)\S\\{nine\_cases}(\#),\39\\{nine\_cases}(\#+9),%
\39\#+18$\par
\P\D \37$\\{thirty\_two\_cases}(\#)\S\\{sixteen\_cases}(\#),\39\\{sixteen%
\_cases}(\#+16)$\par
\P\D \37$\\{thirty\_seven\_cases}(\#)\S\\{thirty\_two\_cases}(\#),\39\\{four%
\_cases}(\#+32),\39\#+36$\par
\P\D \37$\\{sixty\_four\_cases}(\#)\S\\{thirty\_two\_cases}(\#),\39\\{thirty%
\_two\_cases}(\#+32)$\par
\P\D \37$\\{eighty\_three\_cases}(\#)\S\\{sixty\_four\_cases}(\#),\39%
\\{nineteen\_cases}(\#+64)$\par
\P\D \37$\\{one\_sixty\_five\_cases}(\#)\S\\{sixty\_four\_cases}(\#),\39%
\\{sixty\_four\_cases}(\#+64),\39\\{thirty\_seven\_cases}(\#+128)$\par
\fi
\M7. If the \.{DVI} file is badly malformed, the whole process must be aborted;
\.{DVIIMP} will give up, after issuing an error message about the symptoms
that were noticed.
Such errors might be discovered inside of subroutines inside of subroutines,
so a procedure called \\{jump\_out} has been introduced. This procedure, which
simply transfers control to the label \\{final\_end} at the end of the program,
contains the only non-local \&{goto} statement in \.{DVIIMP}.
\Y\P\D \37$\\{abort}(\#)\S$\1\6
\&{begin} \37$\\{print}(\.{\'\ \'},\39\#)$;\5
\\{jump\_out};\6
\&{end}\2\par
\P\D \37$\\{bad\_dvi}(\#)\S\\{abort}(\.{\'Bad\ DVI\ file:\ \'},\39\#,\39\.{\'!%
\'})$\par
\Y\P\4\&{procedure}\1\ \37\\{jump\_out};\2\6
\&{begin} \37\&{goto} \37\\{final\_end};\6
\&{end};\par
\fi
\N8. The character set.
Like all programs written with the \.{WEB} system, \.{DVIIMP} can be
used with any character set. But it uses ASCII code internally, because
the programming for portable input-output is easier when a fixed internal
code is used, and because \.{DVI} files use ASCII code for file names
and certain other strings.
The next few sections of \.{DVIIMP} have therefore been copied from the
analogous ones in the \.{WEB} system routines. They have been considerably
simplified, since \.{DVIIMP} need not deal with the controversial
ASCII codes less than \O{40}. If such codes appear in the \.{DVI} file,
they will be printed as question marks.
\Y\P$\4\X8:Types in the outer block\X\S$\6
$\\{ASCII\_code}=\.{"\ "}\to\.{"\~"}$;\C{a subrange of the integers}\par
\A sections~9, 23, and~154\*.
\U section~3\*.\fi
\M9. The original \PASCAL\ compiler was designed in the late 60s, when six-bit
character sets were common, so it did not make provision for lower case
letters. Nowadays, of course, we need to deal with both upper and lower case
alphabets in a convenient way, especially in a program like \.{DVIIMP}.
So we shall assume that the \PASCAL\ system being used for \.{DVIIMP}
has a character set containing at least the standard visible characters
of ASCII code (\.{"!"} through \.{"\~"}).
Some \PASCAL\ compilers use the original name \\{char} for the data type
associated with the characters in text files, while other \PASCAL s
consider \\{char} to be a 64-element subrange of a larger data type that has
some other name. In order to accommodate this difference, we shall use
the name \\{text\_char} to stand for the data type of the characters in the
output file. We shall also assume that \\{text\_char} consists of
the elements $\\{chr}(\\{first\_text\_char})$ through $\\{chr}(\\{last\_text%
\_char})$,
inclusive. The following definitions should be adjusted if necessary.
\Y\P\D \37$\\{text\_char}\S\\{char}$\C{the data type of characters in text
files}\par
\P\D \37$\\{first\_text\_char}=0$\C{ordinal number of the smallest element of %
\\{text\_char}}\par
\P\D \37$\\{last\_text\_char}=127$\C{ordinal number of the largest element of %
\\{text\_char}}\par
\Y\P$\4\X8:Types in the outer block\X\mathrel{+}\S$\6
$\\{text\_file}=$\1\5
\&{packed} \37\&{file} \1\&{of}\5
\\{text\_char};\2\2\par
\fi
\M10. The \.{DVIIMP} processor converts between ASCII code and
the user's external character set by means of arrays \\{xord} and \\{xchr}
that are analogous to \PASCAL's \\{ord} and \\{chr} functions.
\Y\P$\4\X10:Globals in the outer block\X\S$\6
\4\\{xord}: \37\&{array} $[\\{text\_char}]$ \1\&{of}\5
\\{ASCII\_code};\C{specifies conversion of input characters}\2\6
\4\\{xchr}: \37\&{array} $[0\to255]$ \1\&{of}\5
\\{text\_char};\C{specifies conversion of output characters}\2\par
\A sections~24, 25, 30, 32, 46, 50, 55, 61, 77, 78, 81\*, 84, 92, 100\*, 111,
121, 122, 127, 145, 150, and~155\*.
\U section~3\*.\fi
\M11. Under our assumption that the visible characters of standard ASCII are
all present, the following assignment statements initialize the
\\{xchr} array properly, without needing any system-dependent changes.
\Y\P$\4\X11:Set initial values\X\S$\6
\&{for} $\|i\K0\mathrel{\&{to}}\O{37}$ \1\&{do}\5
$\\{xchr}[\|i]\K\.{\'?\'}$;\2\6
$\\{xchr}[\O{40}]\K\.{\'\ \'}$;\5
$\\{xchr}[\O{41}]\K\.{\'!\'}$;\5
$\\{xchr}[\O{42}]\K\.{\'"\'}$;\5
$\\{xchr}[\O{43}]\K\.{\'\#\'}$;\5
$\\{xchr}[\O{44}]\K\.{\'\$\'}$;\5
$\\{xchr}[\O{45}]\K\.{\'\%\'}$;\5
$\\{xchr}[\O{46}]\K\.{\'\&\'}$;\5
$\\{xchr}[\O{47}]\K\.{\'\'}\.{\'\'}$;\6
$\\{xchr}[\O{50}]\K\.{\'(\'}$;\5
$\\{xchr}[\O{51}]\K\.{\')\'}$;\5
$\\{xchr}[\O{52}]\K\.{\'*\'}$;\5
$\\{xchr}[\O{53}]\K\.{\'+\'}$;\5
$\\{xchr}[\O{54}]\K\.{\',\'}$;\5
$\\{xchr}[\O{55}]\K\.{\'-\'}$;\5
$\\{xchr}[\O{56}]\K\.{\'.\'}$;\5
$\\{xchr}[\O{57}]\K\.{\'/\'}$;\6
$\\{xchr}[\O{60}]\K\.{\'0\'}$;\5
$\\{xchr}[\O{61}]\K\.{\'1\'}$;\5
$\\{xchr}[\O{62}]\K\.{\'2\'}$;\5
$\\{xchr}[\O{63}]\K\.{\'3\'}$;\5
$\\{xchr}[\O{64}]\K\.{\'4\'}$;\5
$\\{xchr}[\O{65}]\K\.{\'5\'}$;\5
$\\{xchr}[\O{66}]\K\.{\'6\'}$;\5
$\\{xchr}[\O{67}]\K\.{\'7\'}$;\6
$\\{xchr}[\O{70}]\K\.{\'8\'}$;\5
$\\{xchr}[\O{71}]\K\.{\'9\'}$;\5
$\\{xchr}[\O{72}]\K\.{\':\'}$;\5
$\\{xchr}[\O{73}]\K\.{\';\'}$;\5
$\\{xchr}[\O{74}]\K\.{\'<\'}$;\5
$\\{xchr}[\O{75}]\K\.{\'=\'}$;\5
$\\{xchr}[\O{76}]\K\.{\'>\'}$;\5
$\\{xchr}[\O{77}]\K\.{\'?\'}$;\6
$\\{xchr}[\O{100}]\K\.{\'@\'}$;\5
$\\{xchr}[\O{101}]\K\.{\'A\'}$;\5
$\\{xchr}[\O{102}]\K\.{\'B\'}$;\5
$\\{xchr}[\O{103}]\K\.{\'C\'}$;\5
$\\{xchr}[\O{104}]\K\.{\'D\'}$;\5
$\\{xchr}[\O{105}]\K\.{\'E\'}$;\5
$\\{xchr}[\O{106}]\K\.{\'F\'}$;\5
$\\{xchr}[\O{107}]\K\.{\'G\'}$;\6
$\\{xchr}[\O{110}]\K\.{\'H\'}$;\5
$\\{xchr}[\O{111}]\K\.{\'I\'}$;\5
$\\{xchr}[\O{112}]\K\.{\'J\'}$;\5
$\\{xchr}[\O{113}]\K\.{\'K\'}$;\5
$\\{xchr}[\O{114}]\K\.{\'L\'}$;\5
$\\{xchr}[\O{115}]\K\.{\'M\'}$;\5
$\\{xchr}[\O{116}]\K\.{\'N\'}$;\5
$\\{xchr}[\O{117}]\K\.{\'O\'}$;\6
$\\{xchr}[\O{120}]\K\.{\'P\'}$;\5
$\\{xchr}[\O{121}]\K\.{\'Q\'}$;\5
$\\{xchr}[\O{122}]\K\.{\'R\'}$;\5
$\\{xchr}[\O{123}]\K\.{\'S\'}$;\5
$\\{xchr}[\O{124}]\K\.{\'T\'}$;\5
$\\{xchr}[\O{125}]\K\.{\'U\'}$;\5
$\\{xchr}[\O{126}]\K\.{\'V\'}$;\5
$\\{xchr}[\O{127}]\K\.{\'W\'}$;\6
$\\{xchr}[\O{130}]\K\.{\'X\'}$;\5
$\\{xchr}[\O{131}]\K\.{\'Y\'}$;\5
$\\{xchr}[\O{132}]\K\.{\'Z\'}$;\5
$\\{xchr}[\O{133}]\K\.{\'[\'}$;\5
$\\{xchr}[\O{134}]\K\.{\'\\\'}$;\5
$\\{xchr}[\O{135}]\K\.{\']\'}$;\5
$\\{xchr}[\O{136}]\K\.{\'\↑\'}$;\5
$\\{xchr}[\O{137}]\K\.{\'\_\'}$;\6
$\\{xchr}[\O{140}]\K\.{\'\`\'}$;\5
$\\{xchr}[\O{141}]\K\.{\'a\'}$;\5
$\\{xchr}[\O{142}]\K\.{\'b\'}$;\5
$\\{xchr}[\O{143}]\K\.{\'c\'}$;\5
$\\{xchr}[\O{144}]\K\.{\'d\'}$;\5
$\\{xchr}[\O{145}]\K\.{\'e\'}$;\5
$\\{xchr}[\O{146}]\K\.{\'f\'}$;\5
$\\{xchr}[\O{147}]\K\.{\'g\'}$;\6
$\\{xchr}[\O{150}]\K\.{\'h\'}$;\5
$\\{xchr}[\O{151}]\K\.{\'i\'}$;\5
$\\{xchr}[\O{152}]\K\.{\'j\'}$;\5
$\\{xchr}[\O{153}]\K\.{\'k\'}$;\5
$\\{xchr}[\O{154}]\K\.{\'l\'}$;\5
$\\{xchr}[\O{155}]\K\.{\'m\'}$;\5
$\\{xchr}[\O{156}]\K\.{\'n\'}$;\5
$\\{xchr}[\O{157}]\K\.{\'o\'}$;\6
$\\{xchr}[\O{160}]\K\.{\'p\'}$;\5
$\\{xchr}[\O{161}]\K\.{\'q\'}$;\5
$\\{xchr}[\O{162}]\K\.{\'r\'}$;\5
$\\{xchr}[\O{163}]\K\.{\'s\'}$;\5
$\\{xchr}[\O{164}]\K\.{\'t\'}$;\5
$\\{xchr}[\O{165}]\K\.{\'u\'}$;\5
$\\{xchr}[\O{166}]\K\.{\'v\'}$;\5
$\\{xchr}[\O{167}]\K\.{\'w\'}$;\6
$\\{xchr}[\O{170}]\K\.{\'x\'}$;\5
$\\{xchr}[\O{171}]\K\.{\'y\'}$;\5
$\\{xchr}[\O{172}]\K\.{\'z\'}$;\5
$\\{xchr}[\O{173}]\K\.{\'\{\'}$;\5
$\\{xchr}[\O{174}]\K\.{\'|\'}$;\5
$\\{xchr}[\O{175}]\K\.{\'\}\'}$;\5
$\\{xchr}[\O{176}]\K\.{\'\~\'}$;\6
\&{for} $\|i\K\O{177}\mathrel{\&{to}}255$ \1\&{do}\5
$\\{xchr}[\|i]\K\.{\'?\'}$;\2\par
\A sections~12, 26, 47, 56, 79, 93, 101, 112, and~123.
\U section~3\*.\fi
\M12. The following system-independent code makes the \\{xord} array contain a
suitable inverse to the information in \\{xchr}.
\Y\P$\4\X11:Set initial values\X\mathrel{+}\S$\6
\&{for} $\|i\K\\{first\_text\_char}\mathrel{\&{to}}\\{last\_text\_char}$ \1%
\&{do}\5
$\\{xord}[\\{chr}(\|i)]\K\O{40}$;\2\6
\&{for} $\|i\K\.{"\ "}\mathrel{\&{to}}\.{"\~"}$ \1\&{do}\5
$\\{xord}[\\{xchr}[\|i]]\K\|i$;\2\par
\fi
\N13. Device-independent file format.
Before we get into the details of \.{DVIIMP}, we need to know exactly
what \.{DVI} files are. The form of such files was designed by David R.
Fuchs in 1979. Almost any reasonable typesetting device can be driven by
a program that takes \.{DVI} files as input, and dozens of such
\.{DVI}-to-whatever programs have been written. Thus, it is possible to
print the output of document compilers like \TeX\ on many different kinds
of equipment.
A \.{DVI} file is a stream of 8-bit bytes, which may be regarded as a
series of commands in a machine-like language. The first byte of each command
is the operation code, and this code is followed by zero or more bytes
that provide parameters to the command. The parameters themselves may consist
of several consecutive bytes; for example, the `\\{set\_rule}' command has two
parameters, each of which is four bytes long. Parameters are usually
regarded as nonnegative integers; but four-byte-long parameters,
and shorter parameters that denote distances, can be
either positive or negative. Such parameters are given in two's complement
notation. For example, a two-byte-long distance parameter has a value between
$-2↑{15}$ and $2↑{15}-1$.
A \.{DVI} file consists of a ``preamble,'' followed by a sequence of one
or more ``pages,'' followed by a ``postamble.'' The preamble is simply a
\\{pre} command, with its parameters that define the dimensions used in the
file; this must come first. Each ``page'' consists of a \\{bop} command,
followed by any number of other commands that tell where characters are to
be placed on a physical page, followed by an \\{eop} command. The pages
appear in the order that they were generated, not in any particular
numerical order. If we ignore \\{nop} commands and \\{fnt\_def} commands
(which are allowed between any two commands in the file), each \\{eop}
command is immediately followed by a \\{bop} command, or by a \\{post}
command; in the latter case, there are no more pages in the file, and the
remaining bytes form the postamble. Further details about the postamble
will be explained later.
Some parameters in \.{DVI} commands are ``pointers.'' These are four-byte
quantities that give the location number of some other byte in the file;
the first byte is number~0, then comes number~1, and so on. For example,
one of the parameters of a \\{bop} command points to the previous \\{bop};
this makes it feasible to read the pages in backwards order, in case the
results are being directed to a device that stacks its output face up.
Suppose the preamble of a \.{DVI} file occupies bytes 0 to 99. Now if the
first page occupies bytes 100 to 999, say, and if the second
page occupies bytes 1000 to 1999, then the \\{bop} that starts in byte 1000
points to 100 and the \\{bop} that starts in byte 2000 points to 1000. (The
very first \\{bop}, i.e., the one that starts in byte 100, has a pointer of
$-1$.)
\fi
\M14. The \.{DVI} format is intended to be both compact and easily interpreted
by a machine. Compactness is achieved by making most of the information
implicit instead of explicit. When a \.{DVI}-reading program reads the
commands for a page, it keeps track of several quantities: (a)~The current
font \|f is an integer; this value is changed only
by \\{fnt} and \\{fnt\_num} commands. (b)~The current position on the page
is given by two numbers called the horizontal and vertical coordinates,
\|h and \|v. Both coordinates are zero at the upper left corner of the page;
moving to the right corresponds to increasing the horizontal coordinate, and
moving down corresponds to increasing the vertical coordinate. Thus, the
coordinates are essentially Cartesian, except that vertical directions are
flipped; the Cartesian version of $(\|h,\|v)$ would be $(\|h,-\|v)$. (c)~The
current spacing amounts are given by four numbers \|w, \|x, \|y, and \|z,
where \|w and~\|x are used for horizontal spacing and where \|y and~\|z
are used for vertical spacing. (d)~There is a stack containing
$(\|h,\|v,\|w,\|x,\|y,\|z)$ values; the \.{DVI} commands \\{push} and \\{pop}
are used to
change the current level of operation. Note that the current font~\|f is
not pushed and popped; the stack contains only information about
positioning.
The values of \|h, \|v, \|w, \|x, \|y, and \|z are signed integers having up
to 32 bits, including the sign. Since they represent physical distances,
there is a small unit of measurement such that increasing \|h by~1 means
moving a certain tiny distance to the right. The actual unit of
measurement is variable, as explained below.
\fi
\M15. Here is a list of all the commands that may appear in a \.{DVI} file.
Each
command is specified by its symbolic name (e.g., \\{bop}), its opcode byte
(e.g., 139), and its parameters (if any). The parameters are followed
by a bracketed number telling how many bytes they occupy; for example,
`$\|p[4]$' means that parameter \|p is four bytes long. (A somewhat
similar set of commands is used in \.{GF} files, as will be
explained in a later section).
\yskip\hang\\{set\_char\_0} 0. Typeset character number~0 from font~\|f
such that the reference point of the character is at $(\|h,\|v)$. Then
increase \|h by the width of that character. Note that a character may
have zero or negative width, so one cannot be sure that \|h will advance
after this command; but \|h usually does increase.
\yskip\hang\\{set\_char\_1} through \\{set\_char\_127} (opcodes 1 to 127).
Do the operations of \\{set\_char\_0}; but use the character whose number
matches the opcode, instead of character~0.
\yskip\hang\\{set1} 128 $\|c[1]$. Same as \\{set\_char\_0}, except that
character
number~\|c is typeset. \TeX82 uses this command for characters in the
range $128\L\|c<256$.
\yskip\hang\\{set2} 129 $\|c[2]$. Same as \\{set1}, except that \|c~is two
bytes long, so it is in the range $0\L\|c<65536$. \TeX82 never uses this
command, which is intended for processors that deal with oriental languages;
but \.{DVIIMP} will allow character codes greater than 255, assuming that
they all have the same width as the character whose code is $c \bmod 256$.
\yskip\hang\\{set3} 130 $\|c[3]$. Same as \\{set1}, except that \|c~is three
bytes long, so it can be as large as $2↑{24}-1$.
\yskip\hang\\{set4} 131 $\|c[4]$. Same as \\{set1}, except that \|c~is four
bytes long, possibly even negative. Imagine that.
\yskip\hang\\{set\_rule} 132 $\|a[4]$ $\|b[4]$. Typeset a solid black rectangle
of height \|a and width \|b, with its bottom left corner at $(\|h,\|v)$. Then
set $\|h\K\|h+\|b$. If either $\|a\L0$ or $\|b\L0$, nothing should be typeset.
Note
that if $\|b<0$, the value of \|h will decrease even though nothing else
happens.
Programs that typeset from \.{DVI} files should be careful to make the rules
line up carefully with digitized characters, as explained in connection with
the \\{rule\_pixels} subroutine below.
\yskip\hang\\{put1} 133 $\|c[1]$. Typeset character number~\|c from font~\|f
such that the reference point of the character is at $(\|h,\|v)$. (The `put'
commands are exactly like the `set' commands, except that they simply put out a
character or a rule without moving the reference point afterwards.)
\yskip\hang\\{put2} 134 $\|c[2]$. Same as \\{set2}, except that \|h is not
changed.
\yskip\hang\\{put3} 135 $\|c[3]$. Same as \\{set3}, except that \|h is not
changed.
\yskip\hang\\{put4} 136 $\|c[4]$. Same as \\{set4}, except that \|h is not
changed.
\yskip\hang\\{put\_rule} 137 $\|a[4]$ $\|b[4]$. Same as \\{set\_rule}, except
that
\|h is not changed.
\yskip\hang\\{nop} 138. No operation, do nothing. Any number of \\{nop}'s
may occur between \.{DVI} commands, but a \\{nop} cannot be inserted between
a command and its parameters or between two parameters.
\yskip\hang\\{bop} 139 $c_0[4]$ $c_1[4]$ $\ldots$ $c_9[4]$ $p[4]$. Beginning
of a page: Set $(\|h,\|v,\|w,\|x,\|y,\|z)\K(0,0,0,0,0,0)$ and set the stack
empty. Set
the current font \|f to an undefined value. The ten $c_i$ parameters can
be used to identify pages, if a user wants to print only part of a \.{DVI}
file; \TeX82 gives them the values of \.{\\count0} $\ldots$ \.{\\count9}
at the time \.{\\shipout} was invoked for this page. The parameter \|p
points to the previous \\{bop} command in the file, where the first \\{bop}
has $p=-1$.
\yskip\hang\\{eop} 140. End of page: Print what you have read since the
previous \\{bop}. At this point the stack should be empty. (The \.{DVI}-reading
programs that drive most output devices will have kept a buffer of the
material that appears on the page that has just ended. This material is
largely, but not entirely, in order by \|v coordinate and (for fixed \|v) by
\|h~coordinate; so it usually needs to be sorted into some order that is
appropriate for the device in question. \.{DVIIMP} does not do such sorting.)
\yskip\hang\\{push} 141. Push the current values of $(\|h,\|v,\|w,\|x,\|y,\|z)$
onto the
top of the stack; do not change any of these values. Note that \|f is
not pushed.
\yskip\hang\\{pop} 142. Pop the top six values off of the stack and assign
them to $(\|h,\|v,\|w,\|x,\|y,\|z)$. The number of pops should never exceed the
number
of pushes, since it would be highly embarrassing if the stack were empty
at the time of a \\{pop} command.
\yskip\hang\\{right1} 143 $\|b[1]$. Set $\|h\K\|h+\|b$, i.e., move right \|b
units.
The parameter is a signed number in two's complement notation, $-128\L\|b<128$;
if $\|b<0$, the reference point actually moves left.
\yskip\hang\\{right2} 144 $\|b[2]$. Same as \\{right1}, except that \|b is a
two-byte quantity in the range $-32768\L\|b<32768$.
\yskip\hang\\{right3} 145 $\|b[3]$. Same as \\{right1}, except that \|b is a
three-byte quantity in the range $\hbox{$-2↑{23}$}\L\|b<\hbox{$2↑{23}$}$.
\yskip\hang\\{right4} 146 $\|b[4]$. Same as \\{right1}, except that \|b is a
four-byte quantity in the range $\hbox{$-2↑{31}$}\L\|b<\hbox{$2↑{31}$}$.
\yskip\hang\\{w0} 147. Set $\|h\K\|h+\|w$; i.e., move right \|w units. With
luck,
this parameterless command will usually suffice, because the same kind of
motion
will occur several times in succession; the following commands explain how
\|w gets particular values.
\yskip\hang\\{w1} 148 $\|b[1]$. Set $\|w\K\|b$ and $\|h\K\|h+\|b$. The value of
\|b is a
signed quantity in two's complement notation, $-128\L\|b<128$. This command
changes the current \|w~spacing and moves right by \|b.
\yskip\hang\\{w2} 149 $\|b[2]$. Same as \\{w1}, but \|b is a two-byte-long
parameter, $-32768\L\|b<32768$.
\yskip\hang\\{w3} 150 $\|b[3]$. Same as \\{w1}, but \|b is a three-byte-long
parameter, $\hbox{$-2↑{23}$}\L\|b<\hbox{$2↑{23}$}$.
\yskip\hang\\{w4} 151 $\|b[4]$. Same as \\{w1}, but \|b is a four-byte-long
parameter, $\hbox{$-2↑{31}$}\L\|b<\hbox{$2↑{31}$}$.
\yskip\hang\\{x0} 152. Set $\|h\K\|h+\|x$; i.e., move right \|x units. The `%
\|x'
commands are like the `\|w' commands except that they involve \|x instead
of \|w.
\yskip\hang\\{x1} 153 $\|b[1]$. Set $\|x\K\|b$ and $\|h\K\|h+\|b$. The value of
\|b is a
signed quantity in two's complement notation, $-128\L\|b<128$. This command
changes the current \|x~spacing and moves right by \|b.
\yskip\hang\\{x2} 154 $\|b[2]$. Same as \\{x1}, but \|b is a two-byte-long
parameter, $-32768\L\|b<32768$.
\yskip\hang\\{x3} 155 $\|b[3]$. Same as \\{x1}, but \|b is a three-byte-long
parameter, $\hbox{$-2↑{23}$}\L\|b<\hbox{$2↑{23}$}$.
\yskip\hang\\{x4} 156 $\|b[4]$. Same as \\{x1}, but \|b is a four-byte-long
parameter, $\hbox{$-2↑{31}$}\L\|b<\hbox{$2↑{31}$}$.
\yskip\hang\\{down1} 157 $\|a[1]$. Set $\|v\K\|v+\|a$, i.e., move down \|a
units.
The parameter is a signed number in two's complement notation, $-128\L\|a<128$;
if $\|a<0$, the reference point actually moves up.
\yskip\hang\\{down2} 158 $\|a[2]$. Same as \\{down1}, except that \|a is a
two-byte quantity in the range $-32768\L\|a<32768$.
\yskip\hang\\{down3} 159 $\|a[3]$. Same as \\{down1}, except that \|a is a
three-byte quantity in the range $\hbox{$-2↑{23}$}\L\|a<\hbox{$2↑{23}$}$.
\yskip\hang\\{down4} 160 $\|a[4]$. Same as \\{down1}, except that \|a is a
four-byte quantity in the range $\hbox{$-2↑{31}$}\L\|a<\hbox{$2↑{31}$}$.
\yskip\hang\\{y0} 161. Set $\|v\K\|v+\|y$; i.e., move down \|y units. With
luck,
this parameterless command will usually suffice, because the same kind of
motion
will occur several times in succession; the following commands explain how
\|y gets particular values.
\yskip\hang\\{y1} 162 $\|a[1]$. Set $\|y\K\|a$ and $\|v\K\|v+\|a$. The value of
\|a is a
signed quantity in two's complement notation, $-128\L\|a<128$. This command
changes the current \|y~spacing and moves down by \|a.
\yskip\hang\\{y2} 163 $\|a[2]$. Same as \\{y1}, but \|a is a two-byte-long
parameter, $-32768\L\|a<32768$.
\yskip\hang\\{y3} 164 $\|a[3]$. Same as \\{y1}, but \|a is a three-byte-long
parameter, $\hbox{$-2↑{23}$}\L\|a<\hbox{$2↑{23}$}$.
\yskip\hang\\{y4} 165 $\|a[4]$. Same as \\{y1}, but \|a is a four-byte-long
parameter, $\hbox{$-2↑{31}$}\L\|a<\hbox{$2↑{31}$}$.
\yskip\hang\\{z0} 166. Set $\|v\K\|v+\|z$; i.e., move down \|z units. The `\|z'
commands
are like the `\|y' commands except that they involve \|z instead of \|y.
\yskip\hang\\{z1} 167 $\|a[1]$. Set $\|z\K\|a$ and $\|v\K\|v+\|a$. The value of
\|a is a
signed quantity in two's complement notation, $-128\L\|a<128$. This command
changes the current \|z~spacing and moves down by \|a.
\yskip\hang\\{z2} 168 $\|a[2]$. Same as \\{z1}, but \|a is a two-byte-long
parameter, $-32768\L\|a<32768$.
\yskip\hang\\{z3} 169 $\|a[3]$. Same as \\{z1}, but \|a is a three-byte-long
parameter, $\hbox{$-2↑{23}$}\L\|a<\hbox{$2↑{23}$}$.
\yskip\hang\\{z4} 170 $\|a[4]$. Same as \\{z1}, but \|a is a four-byte-long
parameter, $\hbox{$-2↑{31}$}\L\|a<\hbox{$2↑{31}$}$.
\yskip\hang\\{fnt\_num\_0} 171. Set $\|f\K0$. Font 0 must previously have been
defined by a \\{fnt\_def} instruction, as explained below.
\yskip\hang\\{fnt\_num\_1} through \\{fnt\_num\_63} (opcodes 172 to 234). Set
$\|f\K1$, \dots, $\|f\K63$, respectively.
\yskip\hang\\{fnt1} 235 $\|k[1]$. Set $\|f\K\|k$. \TeX82 uses this command for
font
numbers in the range $64\L\|k<256$.
\yskip\hang\\{fnt2} 236 $\|k[2]$. Same as \\{fnt1}, except that \|k~is two
bytes long, so it is in the range $0\L\|k<65536$. \TeX82 never generates this
command, but large font numbers may prove useful for specifications of
color or texture, or they may be used for special fonts that have fixed
numbers in some external coding scheme.
\yskip\hang\\{fnt3} 237 $\|k[3]$. Same as \\{fnt1}, except that \|k~is three
bytes long, so it can be as large as $2↑{24}-1$.
\yskip\hang\\{fnt4} 238 $\|k[4]$. Same as \\{fnt1}, except that \|k~is four
bytes long; this is for the really big font numbers (and for the negative
ones).
\yskip\hang\\{xxx1} 239 $\|k[1]$ $\|x[\|k]$. This command is undefined in
general; it functions as a $(k+2)$-byte \\{nop} unless special \.{DVI}-reading
programs are being used. \TeX82 generates \\{xxx1} when a short enough
\.{\\special} appears, setting \|k to the number of bytes being sent. It
is recommended that \|x be a string having the form of a keyword followed
by possible parameters relevant to that keyword.
\yskip\hang\\{xxx2} 240 $\|k[2]$ $\|x[\|k]$. Like \\{xxx1}, but $0\L\|k<65536$.
\yskip\hang\\{xxx3} 241 $\|k[3]$ $\|x[\|k]$. Like \\{xxx1}, but $0\L\|k<%
\hbox{$2↑{24}$}$.
\yskip\hang\\{xxx4} 242 $\|k[4]$ $\|x[\|k]$. Like \\{xxx1}, but \|k can be
ridiculously
large. \TeX82 uses \\{xxx4} when \\{xxx1} would be incorrect.
\yskip\hang\\{fnt\_def1} 243 $\|k[1]$ $\|c[4]$ $\|s[4]$ $\|d[4]$ $\|a[1]$ $%
\|l[1]$ $\|n[\|a+\|l]$.
Define font \|k, where $0\L\|k<256$; font definitions will be explained
shortly.
\yskip\hang\\{fnt\_def2} 244 $\|k[2]$ $\|c[4]$ $\|s[4]$ $\|d[4]$ $\|a[1]$ $%
\|l[1]$ $\|n[\|a+\|l]$.
Define font \|k, where $0\L\|k<65536$.
\yskip\hang\\{fnt\_def3} 245 $\|k[3]$ $\|c[4]$ $\|s[4]$ $\|d[4]$ $\|a[1]$ $%
\|l[1]$ $\|n[\|a+\|l]$.
Define font \|k, where $0\L\|k<\hbox{$2↑{24}$}$.
\yskip\hang\\{fnt\_def4} 246 $\|k[4]$ $\|c[4]$ $\|s[4]$ $\|d[4]$ $\|a[1]$ $%
\|l[1]$ $\|n[\|a+\|l]$.
Define font \|k, where $\hbox{$-2↑{31}$}\L\|k<\hbox{$2↑{31}$}$.
\yskip\hang\\{pre} 247 $\|i[1]$ $\\{num}[4]$ $\\{den}[4]$ $\\{mag}[4]$ $\|k[1]$
$\|x[\|k]$.
Beginning of the preamble; this must come at the very beginning of the
file. Parameters \|i, \\{num}, \\{den}, \\{mag}, \|k, and \|x are explained
below.
\yskip\hang\\{post} 248. Beginning of the postamble, see below.
\yskip\hang\\{post\_post} 249. Ending of the postamble, see below.
\yskip\noindent Commands 250--255 are undefined at the present time.
\fi
\M16. \P\D \37$\\{set\_char\_0}=0$\C{typeset character 0 and move right}\par
\P\D \37$\\{set1}=128$\C{typeset a character and move right}\par
\P\D \37$\\{set\_rule}=132$\C{typeset a rule and move right}\par
\P\D \37$\\{put1}=133$\C{typeset a character}\par
\P\D \37$\\{put\_rule}=137$\C{typeset a rule}\par
\P\D \37$\\{nop}=138$\C{no operation}\par
\P\D \37$\\{bop}=139$\C{beginning of page}\par
\P\D \37$\\{eop}=140$\C{ending of page}\par
\P\D \37$\\{push}=141$\C{save the current positions}\par
\P\D \37$\\{pop}=142$\C{restore previous positions}\par
\P\D \37$\\{right1}=143$\C{move right}\par
\P\D \37$\\{w0}=147$\C{move right by \|w}\par
\P\D \37$\\{w1}=148$\C{move right and set \|w}\par
\P\D \37$\\{x0}=152$\C{move right by \|x}\par
\P\D \37$\\{x1}=153$\C{move right and set \|x}\par
\P\D \37$\\{down1}=157$\C{move down}\par
\P\D \37$\\{y0}=161$\C{move down by \|y}\par
\P\D \37$\\{y1}=162$\C{move down and set \|y}\par
\P\D \37$\\{z0}=166$\C{move down by \|z}\par
\P\D \37$\\{z1}=167$\C{move down and set \|z}\par
\P\D \37$\\{fnt\_num\_0}=171$\C{set current font to 0}\par
\P\D \37$\\{fnt1}=235$\C{set current font}\par
\P\D \37$\\{xxx1}=239$\C{extension to \.{DVI} primitives}\par
\P\D \37$\\{xxx4}=242$\C{potentially long extension to \.{DVI} primitives}\par
\P\D \37$\\{fnt\_def1}=243$\C{define the meaning of a font number}\par
\P\D \37$\\{pre}=247$\C{preamble}\par
\P\D \37$\\{post}=248$\C{postamble beginning}\par
\P\D \37$\\{post\_post}=249$\C{postamble ending}\par
\P\D \37$\\{undefined\_commands}\S250,\39251,\39252,\39253,\39254,\39255$\par
\fi
\M17. The preamble contains basic information about the file as a whole. As
stated above, there are six parameters:
$$\hbox{$\|i[1]$ $\\{num}[4]$ $\\{den}[4]$ $\\{mag}[4]$ $\|k[1]$ $\|x[\|k]$.}$$
The \|i byte identifies \.{DVI} format; currently this byte is always set
to~2. (Some day we will set $\|i=3$, when \.{DVI} format makes another
incompatible change---perhaps in 1992.)
The next two parameters, \\{num} and \\{den}, are positive integers that define
the units of measurement; they are the numerator and denominator of a
fraction by which all dimensions in the \.{DVI} file could be multiplied
in order to get lengths in units of $10↑{-7}$ meters. (For example, there are
exactly 7227 \TeX\ points in 254 centimeters, and \TeX82 works with scaled
points where there are $2↑{16}$ sp in a point, so \TeX82 sets $%
\\{num}=25400000$
and $\\{den}=7227\cdot2↑{16}=473628672$.)
The \\{mag} parameter is what \TeX82 calls \.{\\mag}, i.e., 1000 times the
desired magnification. The actual fraction by which dimensions are
multiplied is therefore $mn/1000d$. Note that if a \TeX\ source document
does not call for any `\.{true}' dimensions, and if you change it only by
specifying a different \.{\\mag} setting, the \.{DVI} file that \TeX\
creates will be completely unchanged except for the value of \\{mag} in the
preamble and postamble. (Fancy \.{DVI}-reading programs allow users to
override the \\{mag}~setting when a \.{DVI} file is being printed.)
Finally, \|k and \|x allow the \.{DVI} writer to include a comment, which is
not
interpreted further. The length of comment \|x is \|k, where $0\L\|k<256$.
\Y\P\D \37$\\{id\_byte}=2$\C{identifies the kind of \.{DVI} files described
here}\par
\fi
\M18. Font definitions for a given font number \|k contain further parameters
$$\hbox{$\|c[4]$ $\|s[4]$ $\|d[4]$ $\|a[1]$ $\|l[1]$ $\|n[\|a+\|l]$.}$$
The four-byte value \|c is the check sum that \TeX\ (or whatever program
generated the \.{DVI} file) found in the \.{GF} file for this font;
\|c should match the check sum of the font found by programs that read
this \.{DVI} file.
Parameter \|s contains a fixed-point scale factor that is applied to the
character widths in font \|k; font dimensions in \.{GF} files and other
font files are relative to this quantity, which is always positive and
less than $2↑{27}$. It is given in the same units as the other dimensions
of the \.{DVI} file. Parameter \|d is similar to \|s; it is the ``design
size,'' and it is given in \.{DVI} units that have not been corrected for
the magnification~\\{mag} found in the preamble. Thus, font \|k is to be
used at $\\{mag}\cdot s/1000d$ times its normal size.
The remaining part of a font definition gives the external name of the font,
which is an ASCII string of length $\|a+\|l$. The number \|a is the length
of the ``area'' or directory, and \|l is the length of the font name itself;
the standard local system font area is supposed to be used when $\|a=0$.
The \|n field contains the area in its first \|a bytes.
Font definitions must appear before the first use of a particular font number.
Once font \|k is defined, it must not be defined again; however, we
shall see below that font definitions appear in the postamble as well as
in the pages, so in this sense each font number is defined exactly twice,
if at all. Like \\{nop} commands and \\{xxx} commands, font definitions can
appear before the first \\{bop}, or between an \\{eop} and a \\{bop}.
\fi
\M19. The last page in a \.{DVI} file is followed by `\\{post}'; this command
introduces the postamble, which summarizes important facts that \TeX\ has
accumulated about the file, making it possible to print subsets of the data
with reasonable efficiency. The postamble has the form
$$\vbox{\halign{\hbox{#\hfil}\cr
\\{post} $\|p[4]$ $\\{num}[4]$ $\\{den}[4]$ $\\{mag}[4]$ $\|l[4]$ $\|u[4]$ $%
\|s[2]$ $\|t[2]$\cr
$\langle\,$font definitions$\,\rangle$\cr
\\{post\_post} $\|q[4]$ $\|i[1]$ 223's$[{\G}4]$\cr}}$$
Here \|p is a pointer to the final \\{bop} in the file. The next three
parameters, \\{num}, \\{den}, and \\{mag}, are duplicates of the quantities
that
appeared in the preamble.
Parameters \|l and \|u give respectively the height-plus-depth of the tallest
page and the width of the widest page, in the same units as other dimensions
of the file. These numbers might be used by a \.{DVI}-reading program to
position individual ``pages'' on large sheets of film or paper.
Parameter \|s is the maximum stack depth (i.e., the largest excess of
\\{push} commands over \\{pop} commands) needed to process this file. Then
comes \|t, the total number of pages (\\{bop} commands) present.
The postamble continues with font definitions, which are any number of
\\{fnt\_def} commands as described above, possibly interspersed with \\{nop}
commands. Each font number that is used in the \.{DVI} file must be defined
exactly twice: Once before it is first selected by a \\{fnt} command, and once
in the postamble.
\fi
\M20. The last part of the postamble, following the \\{post\_post} byte that
signifies the end of the font definitions, contains \|q, a pointer to the
\\{post} command that started the postamble. An identification byte, \|i,
comes next; this currently equals~2, as in the preamble.
The \|i byte is followed by four or more bytes that are all equal to
the decimal number 223 (i.e., \O{337} in octal). \TeX\ puts out four to seven
of
these trailing bytes, until the total length of the file is a multiple of
four bytes, since this works out best on machines that pack four bytes per
word; but any number of 223's is allowed, as long as there are at least four
of them. In effect, 223 is a sort of signature that is added at the very end.
This curious way to finish off a \.{DVI} file makes it feasible for
\.{DVI}-reading programs to find the postamble first, on most computers,
even though \TeX\ wants to write the postamble last. Most operating
systems permit random access to individual words or bytes of a file, so
the \.{DVI} reader can start at the end and skip backwards over the 223's
until finding the identification byte. Then it can back up four bytes, read
\|q, and move to byte \|q of the file. This byte should, of course,
contain the value 248 (\\{post}); now the postamble can be read, so the
\.{DVI} reader discovers all the information needed for typesetting the
pages. Note that it is also possible to skip through the \.{DVI} file at
reasonably high speed to locate a particular page, if that proves
desirable. This saves a lot of time, since \.{DVI} files used in production
jobs tend to be large.
Unfortunately, however, standard \PASCAL\ does not include the ability to
access a random position in a file, or even to determine the length of a file.
Almost all systems nowadays provide the necessary capabilities, so \.{DVI}
format has been designed to work most efficiently with modern operating
systems.
As noted above, \.{DVIIMP} will limit itself to the restrictions of standard
\PASCAL\ if \\{random\_reading} is defined to be \\{false}.
\fi
\N21. The imPRESS file format.
The format of an \.{imPRESS} file is quite similar in many ways to the
format of \.{DVI} files although, of course, the commands are all related
to the specific properties of the \.{IMAGEN} printer. For example,
dimensions are all in units that are derived from the inter-pixel distance
for the printer that is being used (1/300 of an inch on a 300
pixels-per-inch printer). As far as we are concerned, an \.{imPRESS} file
consists of a sequence of bytes although, for some instructions the
associated parameters are made up of a collection of bits that are packed,
rather arbitrarily,
into one or more complete bytes (the commands themselves are never
split between bytes).
As will be explained in more detail later, the \.{IMAGEN} printer provides
facilities for defining certain state variables and for saving and
restoring sets of these variable through the use of push and pop commands.
The Imagen Corporation provides a publication-form-name that is used for
describing the commands and we will, so far as practical, use modified
forms of these publification-form-namess as our names for these commands,
simply prefacing the \.{IMAGEN} command name with \.{im} when this can be done
without making the name too long.
For consistancy, the same conventions are used to
specify the parameters as were used in module 15.
For the reader's convenience, we will list these commands under the same
headings as used in the \.{imPRESS} Programmer's Manual.
Document Structure Commands
\yskip\hang\\{set\_char\_0} 0. Typeset character number~0 from font~\|f
such that the reference point of the character is at $(\|h,\|v)$. Then
increase \|h by the width of that character. Note that a character may
have zero or negative width, so one cannot be sure that \|h will advance
after this command; but \|h usually does increase.
\yskip\hang\\{im\_end\_page} 219. This command declares the current page ready
for printing and starts page layout on a new page. State variables, which
are set once and remain in effect until changed, remain unchanged. These
include the current (\|h,\|v) position so these need to be reset as
desired. Note that some manipulation of data may be needed between a
\.{DVI} \\{eop} and an \.{imPRESS} \\{im\_end\_page}.
\yskip\hang\\{im\_eof} 255. Marks the end of the \.{imPRESS} document. Any
text after this command in the input file will be ignored.
\yskip\hang\\{im\_no\_op} 254. May be used for padding and is ignored. May be
used as a direct translation for \.{DVI}'s \\{nop}.
Coordinate System Commands
\yskip\hang\\{set\_hv\_system} 205 [1]. This command selects the logical
coordinate that is to be used to lay out the pages. This command need not
be given if the default coordinates are to be used (with \|h and \|v axes
equivalent to those for \|x and \|y). The associated byte has a zero
first bit, the next two bits specify the origin, the next two bits specify
the axes and the final three bits specify the orientation.
For details, see the \.{imPRESS} User's Manual.
\yskip\hang\\{set\_abs\_h} 135 [2]. Set the \|h to the value given in the
following 16-bit signed word.
\yskip\hang\\{set\_rel\_h} 136 [2]. Add the value given in the following
16-bit signed word to \|h,
\yskip\hang\\{set\_abs\_v} 137 [2]. Set the \|v to the value given in the
following 16-bit signed word.
\yskip\hang\\{set\_rel\_v} 138 [2]. Add the value given in the following
16-bit signed word to \|v,
Text Positioning Commands
\yskip\hang\\{im\_page} 213. Set both \|h and \|v to zero.
\yskip\hang\\{im\_set\_adv\_dirs} 206 [1]. Set the main and secondary advance
directions as specified in the following byte. The default direction
corresponde to normal english usage.
For details, see the \.{imPRESS} User's Manual.
\yskip\hang\\{im\_mmove} 133 [2]. Displace the current \|h,\|v position in the
main advance direction by the value in the following signed 16¬bit
word. With the default value for \\{im\_set\_adv\_dirs} this command is the
same as \\{im\_set\_rel\_h}.
\yskip\hang\\{im\_smove} 134 [2]. Displace the current \|h,\|v position in the
secondary advance direction by the value in the following signed 16¬bit
word. With the default value for \\{im\_set\_adv\_dirs} this command is the
same as \\{im\_set\_rel\_v}.
\yskip\hang\\{im\_set\_sp} 210 [2]. Set the current inter-word spacing to
the value in the following 16-bit signed word.
We will not use this command as \TeX\ normally handles this matter.
\yskip\hang\\{im\_sp} 128. This command performs an inter-word space of the
size specified by the \\{im\_set\_sp} command.
We will not use this command as \TeX\ normally handles this matter.
\yskip\hang\\{im\_sp1} 129. This command performs an inter-word space of the
size one pixel greater than that specified by the \\{im\_set\_sp} command.
We will not use this command as \TeX\ normally handles this matter.
\yskip\hang\\{im\_mplus} 131. This command adjusts the current position by one
pixel in the main advance direction, that is normally to add one to the
current value of \|h.
\yskip\hang\\{im\_mminus} 132. This command adjusts the current position by
minus one pixel in the main advance direction, that is normally to
subtract one from the current value of \|h.
\yskip\hang\\{im\_crlf} 197. With no special advance directions, this command
sets \|h to the beginning-of-line value and advances \|v by the inter-line
space amount.
\yskip\hang\\{im\_set\_bol} 209 [2]. Set the beginning-of-line margin to the
value specified in the following signed 16-bit word.
\yskip\hang\\{im\_set\_il} 208 [2]. Set the inter-line space to the value
given in the following signed 16-bit word.
Text Printing Commnds
\yskip\hang\\{im\_bgly} 199 [12 plus mask]. This command is used to download
glyphs defined by two bytes specifying <rotation, family, and member>, and
specified by two bytes each for the following four parameters,
width, left-offset, height, and top-offset, and finally by a mask
specifying the complete raster for the glyph within a minimum sized
bounding box (padded at the right with enough empty (white) pixels to
complete an otherwise partially filled byte). The rows are orderd starting
with the top row. The number of bits for this mask is then $((\\{width}+7)%
\mathbin{\&{div}}8)\ast\\{height}$. Once the rotation and family have been
stated, a series of glyphs
from this family may be printed by a string of bytes containing their member
numbers.
\yskip\hang\\{set\_family} 207 [1]. This command sets the current-family to
\\{family} which must lie in the range from 0 to 95.
\yskip\hang\\{im\_member} 0-127. An \.{imPRESS} command code in the range
from 0 and 127 is a member command, calling for the designated member of
the current family to be printed at the current position and for the
printer to advance in the main advance direction by the glyph's associated
advance-width value.
Resident Glyphs
Normally, we will make no use of the resident glyphs provided by the
\.{IMAGEN} processor, since \TeX\ has no knowledge of these. These fonts
are not accessed directly but must be referenced indirectly through member
maps and family tables. For completeness, the commands that are used to
create these maps and family tables are here listed. For details see the
\.{imPRESS} User's Manual.
\yskip\hang\\{create\_map} 222
\yskip\hang\\{create\_family\_table} 221.
Text Rule Command
\yskip\hang\\{im\_brule} 193 w[2] h[2] t[2]. This command prints a rectangle
(either in black or textured) of width w and height h with a top-offset
of t where a positive value means below the current position.
State Saving and Restoring
\yskip\hang\\{set\_push\_mask} 214 [2]. This command specifies which of the
various state variables are to be saved. Nine variables, set by the last 9
bits (with the first 7 bits set to zero) of the associated 16-bit word are
involved, these being: pen-and-texture, interword-space,
beginning-of-line, family, hv-position, advance-direction, origin, and
orientation. These are all marked for saving (set to one) at the beginning
of each document and remain so unless changed by this command.
\yskip\hang\\{im\_push} 211. Save the state variables as prespecified
originally or as altered by the \\{set\_push\_mask} command.
\yskip\hang\\{im\_pop} 212. Restore the state variables saved by the most
recent unmatched \\{im\_push} command.
\fi
\M22. \P\D \37$\\{im\_sp}=128$\C{advance one space}\par
\P\D \37$\\{im\_sp1}=129$\C{advance one space plus 1 pixel}\par
\P\D \37$\\{im\_mplus}=131$\C{advance one pixel}\par
\P\D \37$\\{im\_mminus}=132$\C{back up one pixel}\par
\P\D \37$\\{im\_mmove}=133$\C{move in the main advance direction}\par
\P\D \37$\\{im\_smove}=134$\C{move in the secondary advance direction}\par
\P\D \37$\\{set\_abs\_h}=135$\C{move to \|h position}\par
\P\D \37$\\{set\_rel\_h}=136$\C{move in the \|h direction}\par
\P\D \37$\\{set\_abs\_v}=137$\C{move to \|v position}\par
\P\D \37$\\{set\_rel\_v}=138$\C{move in the \|v direction}\par
\P\D \37$\\{circ\_arc}=150$\C{define a circular path}\par
\P\D \37$\\{ellipse\_arc}=151$\C{define an eliptical path}\par
\P\D \37$\\{circ\_segm}=160$\C{define a pie-shaped path}\par
\P\D \37$\\{im\_brule}=193$\C{print a rule}\par
\P\D \37$\\{im\_crlf}=197$\C{move to the beginning of th next line}\par
\P\D \37$\\{im\_bgly}=199$\C{define a downloaded glyph}\par
\P\D \37$\\{set\_hv\_system}=205$\C{select a logical coordinate system}\par
\P\D \37$\\{im\_set\_adv\_dirs}=206$\C{set the advance directions}\par
\P\D \37$\\{set\_family}=207$\C{set current-family to family}\par
\P\D \37$\\{im\_set\_il}=208$\C{set inter-line spacing}\par
\P\D \37$\\{im\_set\_bol}=209$\C{set margin}\par
\P\D \37$\\{im\_set\_sp}=210$\C{set inter-word spacing}\par
\P\D \37$\\{im\_push}=211$\C{save the state variables}\par
\P\D \37$\\{im\_pop}=212$\C{restore the state variables}\par
\P\D \37$\\{im\_page}=213$\C{set both \|h and \|v to zero}\par
\P\D \37$\\{set\_push\_mask}=214$\C{specify variables to save}\par
\P\D \37$\\{im\_end\_page}=219$\C{end the page}\par
\P\D \37$\\{create\_family\_table}=221$\C{define a family table}\par
\P\D \37$\\{create\_map}=222$\C{create a member map}\par
\P\D \37$\\{set\_pum}=225$\C{append new path or replace path}\par
\P\D \37$\\{create\_path}=230$\C{define a path of segments}\par
\P\D \37$\\{set\_texture}=231$\C{select a texture for drawing}\par
\P\D \37$\\{set\_pen}=232$\C{select a pen width (in pixels)}\par
\P\D \37$\\{fill\_path}=233$\C{shade the ares inside the path}\par
\P\D \37$\\{draw\_path}=234$\C{draw the current path (a line)}\par
\P\D \37$\\{bitmap}=235$\C{print a full bitmap}\par
\P\D \37$\\{set\_magnification}=236$\C{magnify the page (by 1, 2, or 4)}\par
\P\D \37$\\{define\_macro}=242$\C{define a macro}\par
\P\D \37$\\{execute\_macro}=243$\C{execute the named macro}\par
\P\D \37$\\{im\_no\_op}=254$\C{no operation}\par
\P\D \37$\\{im\_eof}=255$\C{end the document}\par
\fi
\N23. Input and Output for binary files.
We have seen that a \.{DVI} file is a sequence of 8-bit bytes. The bytes
appear physically in what is called a `\&{packed} \&{file} \&{of} $0\to255$'
in \PASCAL\ lingo.
Packing is system dependent, and many \PASCAL\ systems fail to implement
such files in a sensible way (at least, from the viewpoint of producing
good production software). For example, some systems treat all
byte-oriented files as text, looking for end-of-line marks and such
things. Therefore some system-dependent code is often needed to deal with
binary files, even though most of the program in this section of
\.{DVIIMP} is written in standard \PASCAL.
One common way to solve the problem is to consider files of \\{integer}
numbers, and to convert an integer in the range $-2↑{31}\L x<2↑{31}$ to
a sequence of four bytes $(a,b,c,d)$ using the following code, which
avoids the controversial integer division of negative numbers:
$$\vbox{\halign{#\hfil\cr
\&{if} $\|x\G0$ \&{then} $\|a\K\|x\mathbin{\&{div}}\O{100000000}$\cr
\&{else} \&{begin} $\|x\K(\|x+\O{10000000000})+\O{10000000000}$; $\|a\K\|x%
\mathbin{\&{div}}\O{100000000}+128$;\cr
\quad \&{end} \cr
$\|x\K\|x\mathbin{\&{mod}}\O{100000000}$;\cr
$\|b\K\|x\mathbin{\&{div}}\O{200000}$; $\|x\K\|x\mathbin{\&{mod}}\O{200000}$;%
\cr
$\|c\K\|x\mathbin{\&{div}}\O{400}$; $\|d\K\|x\mathbin{\&{mod}}\O{400}$;\cr}}$$
The four bytes are then kept in a buffer and output one by one. (On 36-bit
computers, an additional division by 16 is necessary at the beginning.
Another way to separate an integer into four bytes is to use/abuse
\PASCAL's variant records, storing an integer and retrieving bytes that are
packed in the same place; {\sl caveat implementor!\/}) It is also desirable
in some cases to read a hundred or so integers at a time, maintaining a
larger buffer.
We shall stick to simple \PASCAL\ in this program, for reasons of clarity,
even if such simplicity is sometimes unrealistic.
\Y\P$\4\X8:Types in the outer block\X\mathrel{+}\S$\6
$\\{eight\_bits}=0\to255$;\C{unsigned one-byte quantity}\6
$\\{byte\_file}=$\1\5
\&{packed} \37\&{file} \1\&{of}\5
\\{eight\_bits};\C{files that contain binary data}\2\2\par
\fi
\M24. The program deals with four binary file variables: \\{dvi\_file} is the
main
input file that we are translating into symbolic form, \\{gf\_file} is
the generic font file from which the font information is being read,
\\{tfm\_file} is the font-metric file that is used for width information
in those cases where this information is available but the corresponding
\\{gf\_file} is not, and
\\{im\_file} is the output file that is to be sent to the \.{IMAGEN} printer.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{dvi\_file}: \37\\{byte\_file};\C{the stuff we are transcribing to the
IMAGEN}\6
\4\\{gf\_file}: \37\\{byte\_file};\C{a generic font file}\6
\4\\{tfm\_file}: \37\\{byte\_file};\C{a generic font file}\6
\4\\{im\_file}: \37\\{byte\_file};\C{the output file}\par
\fi
\M25. Special considerations are involved in restricting the range of pages
that one may want to print since the $\\{count}[0]$ numbers that the \\{dvi}
file reports may be either positive (the usual case) or negative to signal
that the page numbers are to be printed in italics. The way that these
numbers are used will be system dependent and we will simply list here the
procedures that will be so used. Only $\\{count}[0]$ will be used (as defined
in \.{PLAIN} and the remaining \\{count} numbers will be ignored.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{start\_page}: \37\\{integer};\C{the first page to print}\6
\4\\{num\_pages}: \37\\{integer};\C{the number of pages to be printed}\6
\4\\{last\_page}: \37\\{integer};\C{the last page to print}\6
\4\\{copies}: \37\\{integer};\C{the number of copies requested}\par
\fi
\M26. \P$\X11:Set initial values\X\mathrel{+}\S$\6
$\\{start\_page}\K1$;\5
$\\{last\_page}\K\\{max\_pages}$;\5
$\\{copies}\K1$;\par
\fi
\M27. The following procedures will be needed.
\Y\P\4\&{procedure}\1\ \37\\{read\_f};\2\6
\&{begin} \37$\\{start\_page}\K0$;\5
$\\{get}(\\{tty})$;\6
\&{while} $(\\{tty}\↑\G\.{\'0\'})\W(\\{tty}\↑\L\.{\'9\'})$ \1\&{do}\6
\&{begin} \37$\\{start\_page}\K\\{start\_page}\ast10+\\{xord}[\\{tty}\↑]-%
\.{"0"}$;\5
$\\{get}(\\{tty})$;\6
\&{end};\2\6
\&{end};\7
\4\&{procedure}\1\ \37\\{read\_n};\2\6
\&{begin} \37$\\{num\_pages}\K0$;\5
$\\{get}(\\{tty})$;\6
\&{while} $(\\{tty}\↑\G\.{\'0\'})\W(\\{tty}\↑\L\.{\'9\'})$ \1\&{do}\6
\&{begin} \37$\\{num\_pages}\K\\{num\_pages}\ast10+\\{xord}[\\{tty}\↑]-%
\.{"0"}$;\5
$\\{get}(\\{tty})$;\6
\&{end};\2\6
$\\{last\_page}\K\\{start\_page}+\\{num\_pages}-1$;\6
\&{end};\7
\4\&{procedure}\1\ \37\\{read\_c};\2\6
\&{begin} \37$\\{copies}\K0$;\5
$\\{get}(\\{tty})$;\6
\&{while} $(\\{tty}\↑\G\.{\'0\'})\W(\\{tty}\↑\L\.{\'9\'})$ \1\&{do}\6
\&{begin} \37$\\{copies}\K\\{copies}\ast10+\\{xord}[\\{tty}\↑]-\.{"0"}$;\5
$\\{get}(\\{tty})$;\6
\&{end};\2\6
\&{end};\par
\fi
\M28\*. To prepare the input files, we \\{reset} them. An extension of
\PASCAL\ is needed in the case of \\{gf\_file} and of \\{tfm\_file},
since we want to associate them
with external files whose names are specified dynamically (i.e., not
known at compile time). The following code assumes that `$\\{reset}(\|f,\|s)$'
does this, when \|f is a file variable and \|s is a string variable that
specifies the file name. If $\\{eof}(\|f)$ is true immediately after
$\\{reset}(\|f,\|s)$ has acted, we assume that no file named \|s is accessible.
\Y\P\4\&{procedure}\1\ \37$\\{esp}(\mathop{\&{var}}\\{dvi\_file},\39\\{im%
\_file}:\|f\J\|i\J\|l\J\|e)$;\5
\\{extern};\5
\hbox{\2}\6
\C{spools the \\{im\_file} under the \\{dvi\_file} name}\7
\4\&{function}\1\ \37\\{rescan}: \37\\{boolean};\5
\\{extern};\5
\hbox{\2}\C{puts the command line into the terminal buffer, or returns %
\\{false} if there was no command line}\7
\4\&{procedure}\1\ \37$\\{cur\_nam}(\mathop{\&{var}}\\{chan}:\|f\J\|i\J\|l\J%
\|e;\,\35\mathop{\&{var}}\|s:\\{string})$;\5
\\{extern};\5
\hbox{\2}\7
\4\&{function} \1\ \\{erstat} ( $\mathop{\&{var}}\|f:$ \&{file} ) : %
\\{integer};\5
\\{extern};\5
\hbox{/2}\7
\4\&{procedure}\1\ \37\\{open\_dvi\_file};\C{prepares to read packed bytes in %
\\{dvi\_file}}\6
\4\&{label} \37223;\6
\4\&{var} \37\|i: \37\\{integer};\5
$\\{seen\_dot},\39\\{seen\_left\_bracket},\39\\{seen\_right\_bracket}$: \37%
\\{boolean};\2\6
\&{begin} \37\&{if} $\\{rescan}$ \1\&{then}\6
\&{begin} \37$\\{read\_ln}(\\{tty})$;\6
\&{while} $(\R\\{eoln}(\\{tty}))\W(\\{tty}\↑\I\.{\';\'})$ \1\&{do}\5
$\\{get}(\\{tty})$;\2\6
\&{end};\2\6
\&{if} $\\{eoln}(\\{tty})$ \1\&{then}\5
$\\{write}(\\{tty},\39\.{\'DVI\ file?\ \'})$;\2\6
\4223: \37$\|i\K1$;\5
$\\{get}(\\{tty})$;\5
$\\{seen\_dot}\K\\{false}$;\5
$\\{seen\_left\_bracket}\K\\{false}$;\5
$\\{seen\_right\_bracket}\K\\{false}$;\6
\&{while} $\R\\{eoln}(\\{tty})$ \1\&{do}\6
\&{begin} \37\&{if} $\\{tty}\↑=\.{\'.\'}$ \1\&{then}\5
$\\{seen\_dot}\K\\{true}$\6
\4\&{else} \&{if} $\\{tty}\↑=\.{\']\'}$ \1\&{then}\5
$\\{seen\_right\_bracket}\K\\{true}$\6
\4\&{else} \&{if} $\\{tty}\↑=\.{\'[\'}$ \1\&{then}\6
\&{begin} \37\&{if} $\R\\{seen\_dot}$ \1\&{then}\6
\&{begin} \37$\\{seen\_dot}\K\\{true}$;\5
$\\{dvi\_name}[\|i]\K\.{\'.\'}$;\5
$\\{incr}(\|i)$;\5
$\\{dvi\_name}[\|i]\K\.{\'D\'}$;\5
$\\{incr}(\|i)$;\5
$\\{dvi\_name}[\|i]\K\.{\'V\'}$;\5
$\\{incr}(\|i)$;\5
$\\{dvi\_name}[\|i]\K\.{\'I\'}$;\5
$\\{incr}(\|i)$;\6
\&{end};\2\6
$\\{seen\_left\_bracket}\K\\{true}$\6
\&{end};\2\2\2\6
$\\{dvi\_name}[\|i]\K\\{tty}\↑$;\5
$\\{incr}(\|i)$;\5
$\\{get}(\\{tty})$;\6
\&{end};\2\6
\&{if} $\R\\{seen\_dot}$ \1\&{then}\6
\&{begin} \37$\\{dvi\_name}[\|i]\K\.{\'.\'}$;\5
$\\{incr}(\|i)$;\5
$\\{dvi\_name}[\|i]\K\.{\'D\'}$;\5
$\\{incr}(\|i)$;\5
$\\{dvi\_name}[\|i]\K\.{\'V\'}$;\5
$\\{incr}(\|i)$;\5
$\\{dvi\_name}[\|i]\K\.{\'I\'}$;\5
$\\{incr}(\|i)$;\6
\&{end};\2\6
\&{if} $\\{seen\_left\_bracket}\W\R\\{seen\_right\_bracket}$ \1\&{then}\6
\&{begin} \37$\\{dvi\_name}[\|i]\K\.{\']\'}$;\5
$\\{incr}(\|i)$;\6
\&{end};\2\6
\&{while} $\|i<\\{f\_name\_size}$ \1\&{do}\6
\&{begin} \37$\\{dvi\_name}[\|i]\K\.{\'\ \'}$;\5
$\\{incr}(\|i)$;\6
\&{end};\2\6
$\\{reset}(\\{dvi\_file},\39\\{dvi\_name},\39\.{\'/B:8/N:9/O\'})$;\6
\&{if} $(\\{erstat}(\\{dvi\_file})\mathbin{\&{mod}}\O{20000})>0$ \1\&{then}\6
\&{begin} \37$\\{write}(\\{tty},\39\.{\'.DVI\ file?\ \'})$;\5
\&{goto} \37223;\6
\&{end};\2\6
$\\{cur\_loc}\K0$;\6
\&{end};\7
\4\&{procedure}\1\ \37\\{open\_gf\_file};\C{prepares to read packed bytes in %
\\{gf\_file}}\2\6
\&{begin} \37$\\{reset}(\\{gf\_file},\39\\{cur\_name},\39\.{\'/B:8/O/N:9\'})$;\5
$\\{cur\_gf\_loc}\K0$;\6
\&{end};\7
\4\&{procedure}\1\ \37\\{open\_tfm\_file};\C{prepares to read packed bytes in %
\\{tfm\_file}}\2\6
\&{begin} \37$\\{reset}(\\{tfm\_file},\39\\{cur\_tfm\_name},\39\.{\'/B:8/O/N:9%
\'})$;\5
$\\{cur\_gf\_loc}\K0$;\6
\&{end};\par
\fi
\M29\*. To prepare the \\{im\_file} for output, we \\{rewrite} it.
\Y\P\4\&{procedure}\1\ \37\\{open\_im\_file};\C{prepares to write packed bytes
in \\{im\_file}}\6
\4\&{label} \37\\{done};\6
\4\&{var} \37$\|i,\39\|j$: \37\\{integer};\2\6
\&{begin} \37$\\{cur\_nam}(\\{dvi\_file},\39\\{imp\_name})$;\5
$\|i\K1$;\6
\&{while} $(\\{imp\_name}[\|i]>\.{\'.\'})\W(\\{imp\_name}[\|i]\I\.{\'[\'})$ \1%
\&{do}\5
$\\{incr}(\|i)$;\C{skip to dot or bracket or space or null}\2\6
$\|j\K\|i-1$;\5
$\\{imp\_name}[\|i]\K\.{\'.\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'L\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'P\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'T\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'[\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'S\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'P\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'L\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\',\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'S\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'Y\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'S\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\']\'}$;\5
$\\{incr}(\|i)$;\5
$\\{imp\_name}[\|i]\K\.{\'\ \'}$;\6
\&{while} $\\{true}$ \1\&{do}\6
\&{begin} \37$\\{reset}(\\{im\_file},\39\\{imp\_name},\39\.{\'/O\'})$;\6
\&{if} $(\\{erstat}(\\{im\_file})\mathbin{\&{mod}}\O{20000})>0$ \1\&{then}\5
\&{goto} \37\\{done};\2\6
$\\{imp\_name}[\|j]\K\\{chr}(\\{ord}(\\{imp\_name}[\|j])+1)$;\6
\&{if} $\\{imp\_name}[\|j]>\.{\'Z\'}$ \1\&{then}\6
\&{begin} \37$\\{imp\_name}[\|j-1]\K\\{chr}(\\{ord}(\\{imp\_name}[\|j-1])+1)$;\5
$\\{imp\_name}[\|j]\K\.{\'A\'}$;\6
\&{if} $\\{imp\_name}[\|j-1]>\.{\'Z\'}$ \1\&{then}\5
$\\{imp\_name}[\|j-1]\K\.{\'A\'}$;\2\6
\&{end};\2\6
\&{end};\2\6
\4\\{done}: \37$\\{rewrite}(\\{im\_file},\39\\{imp\_name},\39\.{%
\'/B:8/N:9/P:256\'})$;\5
$\\{im\_byte\_no}\K0$;\6
\&{end};\par
\fi
\M30. If you looked carefully at the preceding code, you probably asked,
``What are \\{cur\_loc} and \\{cur\_name}?'' Good question. They're global
variables: \\{cur\_loc} is the number of the byte about to be read next from
\\{dvi\_file}, and \\{cur\_name} is a string variable that will be set to the
generic font file name before \\{open\_gf\_file} is called. While we are at
it, we will also declare \\{cur\_gf\_loc}.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{cur\_loc}: \37\\{integer};\C{where we are about to look, in \\{dvi\_file}}%
\6
\4\\{cur\_gf\_loc}: \37\\{integer};\C{where we are about to look, in \\{gf%
\_file}}\6
\4\\{cur\_name}: \37\&{packed} \37\&{array} $[1\to\\{name\_length}]$ \1\&{of}\5
\\{char};\C{external name, with no lower case letters}\2\6
\4\\{cur\_tfm\_name}: \37\&{packed} \37\&{array} $[1\to\\{name\_length}]$ \1%
\&{of}\5
\\{char};\C{external name, with no lower case letters}\2\6
\4\\{im\_byte\_no}: \37\\{integer};\C{where we are about to write, in \\{im%
\_file}}\par
\fi
\M31. We shall use a set of simple functions to read the next byte or bytes
from a \\{gf\_file}.
\Y\P\4\&{function}\1\ \37\\{gf\_byte}: \37\\{integer};\C{returns the next
byte, unsigned}\6
\4\&{var} \37\|b: \37\\{eight\_bits};\2\6
\&{begin} \37\&{if} $\\{eof}(\\{gf\_file})$ \1\&{then}\5
$\\{gf\_byte}\K0$\6
\4\&{else} \&{begin} \37$\\{read}(\\{gf\_file},\39\|b)$;\5
$\\{incr}(\\{cur\_gf\_loc})$;\5
$\\{gf\_byte}\K\|b$;\6
\&{end};\2\6
\&{end};\7
\4\&{function}\1\ \37\\{gf\_two\_bytes}: \37\\{integer};\C{returns the next
two bytes, unsigned}\6
\4\&{var} \37$\|a,\39\|b$: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{gf\_file},\39\|a)$;\5
$\\{read}(\\{gf\_file},\39\|b)$;\5
$\\{cur\_gf\_loc}\K\\{cur\_gf\_loc}+2$;\5
$\\{gf\_two\_bytes}\K\|a\ast256+\|b$;\6
\&{end};\7
\4\&{function}\1\ \37\\{gf\_three\_bytes}: \37\\{integer};\C{returns the next
three bytes, unsigned}\6
\4\&{var} \37$\|a,\39\|b,\39\|c$: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{gf\_file},\39\|a)$;\5
$\\{read}(\\{gf\_file},\39\|b)$;\5
$\\{read}(\\{gf\_file},\39\|c)$;\5
$\\{cur\_gf\_loc}\K\\{cur\_gf\_loc}+3$;\5
$\\{gf\_three\_bytes}\K(\|a\ast256+\|b)\ast256+\|c$;\6
\&{end};\7
\4\&{function}\1\ \37\\{gf\_signed\_quad}: \37\\{integer};\C{returns the next
four bytes, signed}\6
\4\&{var} \37$\|a,\39\|b,\39\|c,\39\|d$: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{gf\_file},\39\|a)$;\5
$\\{read}(\\{gf\_file},\39\|b)$;\5
$\\{read}(\\{gf\_file},\39\|c)$;\5
$\\{read}(\\{gf\_file},\39\|d)$;\5
$\\{cur\_gf\_loc}\K\\{cur\_gf\_loc}+4$;\6
\&{if} $\|a<128$ \1\&{then}\5
$\\{gf\_signed\_quad}\K((\|a\ast256+\|b)\ast256+\|c)\ast256+\|d$\6
\4\&{else} $\\{gf\_signed\_quad}\K(((\|a-256)\ast256+\|b)\ast256+\|c)\ast256+%
\|d$;\2\6
\&{end};\par
\fi
\M32. We will refer to \.{TFM} files for character width information in those
cases where \.{.GF} files are not available. We read four bytes at a
time, putting the input into global
variables \\{b0}, \\{b1}, \\{b2}, and \\{b3}, with \\{b0} getting the first
byte and
\\{b3} the fourth.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4$\\{b0},\39\\{b1},\39\\{b2},\39\\{b3}$: \37\\{eight\_bits};\C{four bytes
input at once}\par
\fi
\M33. The \\{read\_tfm\_word} procedure sets \\{b0} through \\{b3} to the next
four bytes in the current \.{TFM} file.
\Y\P\4\&{procedure}\1\ \37\\{read\_tfm\_word};\2\6
\&{begin} \37$\\{read}(\\{tfm\_file},\39\\{b0})$;\5
$\\{read}(\\{tfm\_file},\39\\{b1})$;\5
$\\{read}(\\{tfm\_file},\39\\{b2})$;\5
$\\{read}(\\{tfm\_file},\39\\{b3})$;\6
\&{end};\par
\fi
\M34. We shall use another set of simple functions to read the next byte or
bytes from \\{dvi\_file}. There are seven possibilities, each of which is
treated as a separate function in order to minimize the overhead for
subroutine calls.
\Y\P\4\&{function}\1\ \37\\{get\_byte}: \37\\{integer};\C{returns the next
byte, unsigned}\6
\4\&{var} \37\|b: \37\\{eight\_bits};\2\6
\&{begin} \37\&{if} $\\{eof}(\\{dvi\_file})$ \1\&{then}\5
$\\{get\_byte}\K0$\6
\4\&{else} \&{begin} \37$\\{read}(\\{dvi\_file},\39\|b)$;\5
$\\{incr}(\\{cur\_loc})$;\5
$\\{get\_byte}\K\|b$;\6
\&{end};\2\6
\&{end};\7
\4\&{function}\1\ \37\\{signed\_byte}: \37\\{integer};\C{returns the next
byte, signed}\6
\4\&{var} \37\|b: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{dvi\_file},\39\|b)$;\5
$\\{incr}(\\{cur\_loc})$;\6
\&{if} $\|b<128$ \1\&{then}\5
$\\{signed\_byte}\K\|b$\ \&{else} $\\{signed\_byte}\K\|b-256$;\2\6
\&{end};\7
\4\&{function}\1\ \37\\{get\_two\_bytes}: \37\\{integer};\C{returns the next
two bytes, unsigned}\6
\4\&{var} \37$\|a,\39\|b$: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{dvi\_file},\39\|a)$;\5
$\\{read}(\\{dvi\_file},\39\|b)$;\5
$\\{cur\_loc}\K\\{cur\_loc}+2$;\5
$\\{get\_two\_bytes}\K\|a\ast256+\|b$;\6
\&{end};\7
\4\&{function}\1\ \37\\{signed\_pair}: \37\\{integer};\C{returns the next two
bytes, signed}\6
\4\&{var} \37$\|a,\39\|b$: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{dvi\_file},\39\|a)$;\5
$\\{read}(\\{dvi\_file},\39\|b)$;\5
$\\{cur\_loc}\K\\{cur\_loc}+2$;\6
\&{if} $\|a<128$ \1\&{then}\5
$\\{signed\_pair}\K\|a\ast256+\|b$\6
\4\&{else} $\\{signed\_pair}\K(\|a-256)\ast256+\|b$;\2\6
\&{end};\7
\4\&{function}\1\ \37\\{get\_three\_bytes}: \37\\{integer};\C{returns the next
three bytes, unsigned}\6
\4\&{var} \37$\|a,\39\|b,\39\|c$: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{dvi\_file},\39\|a)$;\5
$\\{read}(\\{dvi\_file},\39\|b)$;\5
$\\{read}(\\{dvi\_file},\39\|c)$;\5
$\\{cur\_loc}\K\\{cur\_loc}+3$;\5
$\\{get\_three\_bytes}\K(\|a\ast256+\|b)\ast256+\|c$;\6
\&{end};\7
\4\&{function}\1\ \37\\{signed\_trio}: \37\\{integer};\C{returns the next
three bytes, signed}\6
\4\&{var} \37$\|a,\39\|b,\39\|c$: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{dvi\_file},\39\|a)$;\5
$\\{read}(\\{dvi\_file},\39\|b)$;\5
$\\{read}(\\{dvi\_file},\39\|c)$;\5
$\\{cur\_loc}\K\\{cur\_loc}+3$;\6
\&{if} $\|a<128$ \1\&{then}\5
$\\{signed\_trio}\K(\|a\ast256+\|b)\ast256+\|c$\6
\4\&{else} $\\{signed\_trio}\K((\|a-256)\ast256+\|b)\ast256+\|c$;\2\6
\&{end};\7
\4\&{function}\1\ \37\\{signed\_quad}: \37\\{integer};\C{returns the next four
bytes, signed}\6
\4\&{var} \37$\|a,\39\|b,\39\|c,\39\|d$: \37\\{eight\_bits};\2\6
\&{begin} \37$\\{read}(\\{dvi\_file},\39\|a)$;\5
$\\{read}(\\{dvi\_file},\39\|b)$;\5
$\\{read}(\\{dvi\_file},\39\|c)$;\5
$\\{read}(\\{dvi\_file},\39\|d)$;\5
$\\{cur\_loc}\K\\{cur\_loc}+4$;\6
\&{if} $\|a<128$ \1\&{then}\5
$\\{signed\_quad}\K((\|a\ast256+\|b)\ast256+\|c)\ast256+\|d$\6
\4\&{else} $\\{signed\_quad}\K(((\|a-256)\ast256+\|b)\ast256+\|c)\ast256+\|d$;%
\2\6
\&{end};\par
\fi
\M35. Finally we come to the routines that are used only if \\{random\_reading}
is
\\{true}. The driver program below needs two such routines: \\{dvi\_length}
should
compute the total number of bytes in \\{dvi\_file}, possibly also
causing $\\{eof}(\\{dvi\_file})$ to be true; and $\\{move\_to\_byte}(\|n)$
should position \\{dvi\_file} so that the next \\{get\_byte} will read byte %
\|n,
starting with $\|n=0$ for the first byte in the file.
Such routines are, of course, highly system dependent. They are implemented
here in terms of two assumed system routines called \\{set\_pos} and \\{cur%
\_pos}.
The call $\\{set\_pos}(\|f,\|n)$ moves to item \|n in file \|f, unless \|n is
negative or larger than the total number of items in \|f; in the latter
case, $\\{set\_pos}(\|f,\|n)$ moves to the end of file \|f.
The call $\\{cur\_pos}(\|f)$ gives the total number of items in \|f, if
$\\{eof}(\|f)$ is true; we use \\{cur\_pos} only in such a situation.
\Y\P\4\&{function}\1\ \37\\{dvi\_length}: \37\\{integer};\2\6
\&{begin} \37$\\{set\_pos}(\\{dvi\_file},\39-1)$;\5
$\\{dvi\_length}\K\\{cur\_pos}(\\{dvi\_file})$;\6
\&{end};\7
\4\&{procedure}\1\ \37$\\{move\_to\_byte}(\|n:\\{integer})$;\2\6
\&{begin} \37$\\{set\_pos}(\\{dvi\_file},\39\|n)$;\5
$\\{cur\_loc}\K\|n$;\6
\&{end};\par
\fi
\M36. We face a similar problem in dealing with the \.{GF} files so perhaps we
should deal with this problem at this time. We will need two special
routines, one to determine the byte length of the individual \.{GF} files
and the second to position \\{gf\_file} so that the next \\{gf\_byte} will read
byte \|n, starting with $\|n=0$ for the first byte in the file.
\Y\P\4\&{function}\1\ \37\\{gf\_length}: \37\\{integer};\2\6
\&{begin} \37$\\{set\_pos}(\\{gf\_file},\39-1)$;\5
$\\{gf\_length}\K\\{cur\_pos}(\\{gf\_file})$;\6
\&{end};\7
\4\&{procedure}\1\ \37$\\{move\_to\_gf\_byte}(\|n:\\{integer})$;\2\6
\&{begin} \37$\\{set\_pos}(\\{gf\_file},\39\|n)$;\5
$\\{cur\_gf\_loc}\K\|n$;\6
\&{end};\par
\fi
\M37. We will also need a simple way of sending bytes, unsigned bytes, and
signed
16-bit words to the \\{im\_file}. While the \.{imPRESS} manual user \\{u\_byte}
for an unsigned byte, we will attach an `s' prefix for the signed case, leaving
\\{im\_byte} to mean an unsigned byte as used elsewhere in this program.
\Y\P\D \37$\\{im\_byte}(\#)\S$\1\6
\&{begin} \37$\\{write}(\\{im\_file},\39\#)$;\5
$\\{incr}(\\{im\_byte\_no})$;\6
\&{end}\2\par
\Y\P\4\&{procedure}\1\ \37$\\{im\_sbyte}(\|w:\\{integer})$;\2\6
\&{begin} \37\&{if} $\|w<0$ \1\&{then}\5
$\|w\K\|w+\H{100}$;\2\6
$\\{im\_byte}(\|w)$;\6
\&{end};\7
\4\&{procedure}\1\ \37$\\{im\_halfword}(\|w:\\{integer})$;\2\6
\&{begin} \37\&{if} $\|w<0$ \1\&{then}\5
$\|w\K\|w+\H{10000}$;\2\6
$\\{im\_byte}(\|w\mathbin{\&{div}}\H{100})$;\5
$\\{im\_byte}(\|w\mathbin{\&{mod}}\H{100})$;\6
\&{end};\par
\fi
\N38. GF file format.
This program, in contrast with many device drivers, gets its font
information directly from the ``generic font'' (\.{GF}) files that are the
most important output produced by the \MF\ program. The term {\sl
generic\/} indicates that this file format doesn't match the conventions
of any name-brand manufacturer; but it is easy to convert \.{GF} files to
the special format required by almost all digital phototypesetting
equipment, if these devices are designed to accept fonts directly.
Alternately, one can translate the \.{GF} and pass the needed raster
information on to the printer at the time that a \.{DVI} file is being
processed, as is done in this program.
There's a strong analogy
between the \.{DVI} files written by \TeX\ and the \.{GF} files written
by \MF; and, in fact, the file formats have a lot in common.
A \.{GF} file is a stream of 8-bit bytes that may be
regarded as a series of commands in a machine-like language. The first
byte of each command is the operation code, and this code is followed by
zero or more bytes that provide parameters to the command. The parameters
themselves may consist of several consecutive bytes; for example, the
`\\{boc}' (beginning of character) command has seven parameters, each of
which is four bytes long. Parameters are usually regarded as nonnegative
integers; but four-byte-long parameters can be either positive or
negative, hence they range in value from $-2↑{31}$ to $2↑{31}-1$.
As in \.{TFM} files, numbers that occupy
more than one byte position appear in BigEndian order,
and negative numbers appear in two's complement notation.
A \.{GF} file consists of a ``preamble,'' followed by a sequence of one or
more ``characters,'' followed by a ``postamble.'' The preamble is simply a
\\{pre} command, with its parameters that introduce the file; this must come
first. Each ``character'' consists of a \\{boc} or a \\{boc1}
command, followed by any
number of other commands that specify ``black'' pixels,
followed by an \\{eoc} command. The characters appear in the order that \MF\
generated them. If we ignore no-op commands (which are allowed between any
two commands in the file), each \\{eoc} command is immediately followed by a
\\{boc} or a \\{boc1}
command, or by a \\{post} command; in the latter case, there are no
more characters in the file, and the remaining bytes form the postamble.
Further details about the postamble will be explained later.
Some parameters in \.{GF} commands are ``pointers.'' These are four-byte
quantities that give the location number of some other byte in the file;
the first file byte is number~0, then comes number~1, and so on.
\fi
\M39. The \.{GF} format is intended to be both compact and easily interpreted
by a machine. Compactness is achieved by making most of the information
relative instead of absolute. When a \.{GF}-reading program reads the
commands for a character, it keeps track of two quantities: (a)~the current
column number,~\|m; and (b)~the current row number,~\|n. These are 32-bit
signed integers, although most actual font formats produced from \.{GF}
files will need to curtail this vast range because of practical
limitations. (\MF\ output will never allow $\vert m\vert$ or $\vert
n\vert$ to exceed 4096, but the \.{GF} format tries to be more general.)
How do \.{GF}'s row and column numbers correspond to the conventions
of \TeX\ and \MF? Well, the ``reference point'' of a character, in \TeX's
view, is considered to be at the lower left corner of the pixel in row~0
and column~0. This point is the intersection of the baseline with the left
edge of the type; it corresponds to location $(0,0)$ in \MF\ programs.
Thus the pixel in \.{GF} row~0 and column~0 is \MF's unit square, comprising
the
region of the plane whose coordinates both lie between 0 and~1. The
pixel in \.{GF} row~\|n and column~\|m consists of the points whose \MF\
coordinates $(\|x,\|y)$ satisfy $\|m\L\|x\L\|m+1$ and $\|n\L\|y\L\|n+1$.
Negative values of
\|m and~\|x correspond to columns of pixels {\sl left\/} of the reference
point; negative values of \|n and~\|y correspond to rows of pixels {\sl
below\/} the baseline.
Besides \|m and \|n, there's also a third aspect of the current
state, namely the \\{paint\_switch}, which is always either \\{black} or
\\{white}. Each \\{paint} command advances \|m by a specified amount~\|d,
and blackens the intervening pixels if $\\{paint\_switch}=\\{black}$; then
the \\{paint\_switch} changes to the opposite state. \.{GF}'s commands are
designed so that \|m will never decrease within a row, and \|n will never
increase within a character; hence there is no way to whiten a pixel that
has been blackened. \.{DVIIMP} does not use a \\{paint\_switch} parameter,
as such, but other programs do and the concept is useful in following
the way that the \\{paint} commands are handled.
\fi
\M40. Here is a list of all the commands that may appear in a \.{GF} file. Each
command is specified by its symbolic name (e.g., \\{boc}), its opcode byte
(e.g., 67), and its parameters (if any). The parameters are followed
by a bracketed number telling how many bytes they occupy; for example,
`$\|d[2]$' means that parameter \|d is two bytes long.
\yskip\hang\\{paint\_0} 0. This is a \\{paint} command with $\|d=0$; it does
nothing but change the \\{paint\_switch} from \\{black} to \\{white} or
vice~versa.
\yskip\hang\\{paint\_1} through \\{paint\_63} (opcodes 1 to 63).
These are \\{paint} commands with $\|d=1$ to~63, defined as follows: If
$\\{paint\_switch}=\\{black}$, blacken \|d~pixels of the current row~\|n,
in columns \|m through $\|m+\|d-1$ inclusive. Then, in any case,
complement the \\{paint\_switch} and advance \|m by~\|d.
\yskip\hang\\{paint1} 64 $\|d[1]$. This is a \\{paint} command with a specified
value of~\|d; \MF\ uses it to paint when $64\L\|d<256$.
\yskip\hang\\{paint2} 65 $\|d[2]$. Same as \\{paint1}, but \|d~can be as high
as~65535.
\yskip\hang\\{paint3} 66 $\|d[3]$. Same as \\{paint1}, but \|d~can be as high
as $2↑{24}-1$. \MF\ never needs this command, and it is hard to imagine
anybody making practical use of it; surely a more compact encoding will be
desirable when characters can be this large. But the command is there,
anyway, just in case.
\yskip\hang\\{boc} 67 $\|c[4]$ $\|p[4]$ $\\{min\_m}[4]$ $\\{max\_m}[4]$ $\\{min%
\_n}[4]$
$\\{max\_n}[4]$. Beginning of a character: Here \|c is the character code, and
\|p points to the previous character beginning (if any) for characters having
this code number modulo 256. (The pointer \|p is $-1$ if there was no
prior character with an equivalent code.) The values of registers \|m and \|n
defined by the instructions that follow for this character must
satisfy $\\{min\_m}\L\|m\L\\{max\_m}$ and $\\{min\_n}\L\|n\L\\{max\_n}$. (The
values of \\{max\_m} and
\\{min\_n} need not be the tightest bounds possible.) When a \.{GF}-reading
program sees a \\{boc}, it can use \\{min\_m}, \\{max\_m}, \\{min\_n}, and %
\\{max\_n} to
initialize the bounds of an array. Then it sets $\|m\K\\{min\_m}$, $\|n\K\\{max%
\_n}$, and
$\\{paint\_switch}\K\\{white}$.
\yskip\hang\\{boc1} 68 $\|c[1]$ $\\{del\_m}[1]$ $\\{max\_m}[1]$ $\\{del\_n}[1]$
$\\{max\_n}[1]$.
Same as \\{boc}, but \|p is assumed to be~$-1$; also $\\{del\_m}=\\{max\_m}-%
\\{min\_m}$
and $\\{del\_n}=\\{max\_n}-\\{min\_n}$ are given instead of \\{min\_m} and %
\\{min\_n}.
The one-byte parameters must be between 0 and 255, inclusive.
\ (This abbreviated \\{boc} saves 19~bytes per character, in common cases.)
\yskip\hang\\{eoc} 69. End of character: All pixels blackened so far
constitute the pattern for this character. In particular, a completely
blank character might have \\{eoc} immediately following \\{boc}.
\yskip\hang\\{skip0} 70. Decrease \|n by 1 and set $\|m\K\\{min\_m}$,
$\\{paint\_switch}\K\\{white}$. \ (This finishes one row and begins another,
ready to whiten the leftmost pixel in the new row.)
\yskip\hang\\{skip1} 71 $\|d[1]$. Decrease \|n by $\|d+1$, set $\|m\K\\{min%
\_m}$, and set
$\\{paint\_switch}\K\\{white}$. This is a way to produce \|d all-white rows.
\yskip\hang\\{skip2} 72 $\|d[2]$. Same as \\{skip1}, but \|d can be as large
as 65535.
\yskip\hang\\{skip3} 73 $\|d[3]$. Same as \\{skip1}, but \|d can be as large
as $2↑{24}-1$. \MF\ obviously never needs this command.
\yskip\hang\\{new\_row\_0} 74. Decrease \|n by 1 and set $\|m\K\\{min\_m}$,
$\\{paint\_switch}\K\\{black}$. \ (This finishes one row and begins another,
ready to {\sl blacken\/} the leftmost pixel in the new row.)
\yskip\hang\\{new\_row\_1} through \\{new\_row\_164} (opcodes 75 to 238). Same
as
\\{new\_row\_0}, but with $\|m\K\\{min\_m}+1$ through $\\{min\_m}+164$,
respectively.
\yskip\hang\\{xxx1} 239 $\|k[1]$ $\|x[\|k]$. This command is undefined in
general; it functions as a $(k+2)$-byte \\{no\_op} unless special %
\.{GF}-reading
programs are being used. \MF\ generates \\{xxx} commands when encountering
a \&{special} string; this occurs in the \.{GF} file only between
characters, after the preamble, and before the postamble. However,
\\{xxx} commands might appear anywhere in \.{GF} files generated by other
processors. It is recommended that \|x be a string having the form of a
keyword followed by possible parameters relevant to that keyword.
\yskip\hang\\{xxx2} 240 $\|k[2]$ $\|x[\|k]$. Like \\{xxx1}, but $0\L\|k<65536$.
\yskip\hang\\{xxx3} 241 $\|k[3]$ $\|x[\|k]$. Like \\{xxx1}, but $0\L\|k<%
\hbox{$2↑{24}$}$.
\MF\ uses this when sending a \&{special} string whose length exceeds~255.
\yskip\hang\\{xxx4} 242 $\|k[4]$ $\|x[\|k]$. Like \\{xxx1}, but \|k can be
ridiculously large; \|k mustn't be negative.
\yskip\hang\\{yyy} 243 $\|y[4]$. This command is undefined in general;
it functions as a 5-byte \\{no\_op} unless special \.{GF}-reading programs
are being used. \MF\ puts \\{scaled} numbers into \\{yyy}'s, as a
result of \&{numspecial} commands; the intent is to provide numeric
parameters to \\{xxx} commands that immediately precede.
\yskip\hang\\{no\_op} 244. No operation, do nothing. Any number of \\{no\_op}'s
may occur between \.{GF} commands, but a \\{no\_op} cannot be inserted between
a command and its parameters or between two parameters.
\yskip\hang\\{char\_loc} 245 $\|c[1]$ $\\{dx}[4]$ $\\{dy}[4]$ $\|w[4]$ $%
\|p[4]$.
This command will appear only in the postamble, which will be explained
shortly.
\yskip\hang\\{char\_loc0} 246 $\|c[1]$ $\\{dm}[1]$ $\|w[4]$ $\|p[4]$.
Same as \\{char\_loc}, except that \\{dy} is assumed to be zero, and the value
of~\\{dx} is taken to be $65536\ast\\{dm}$, where $0\L\\{dm}<256$.
\yskip\hang\\{pre} 247 $\|i[1]$ $\|k[1]$ $\|x[\|k]$.
Beginning of the preamble; this must come at the very beginning of the
file. Parameter \|i is an identifying number for \.{GF} format, currently
131. The other information is merely commentary; it is not given
special interpretation like \\{xxx} commands are. (Note that \\{xxx}
commands may immediately follow the preamble, before the first \\{boc}.)
\yskip\hang\\{post} 248. Beginning of the postamble, see below.
\yskip\hang\\{post\_post} 249. Ending of the postamble, see below.
\yskip\noindent Commands 250--255 are undefined at the present time.
\Y\P\D \37$\\{gf\_id\_byte}=131$\C{identifies the kind of \.{GF} files
described here}\par
\fi
\M41. Here are the opcodes that \.{DVIIMP} actually refers to.
\Y\P\D \37$\\{paint\_0}=0$\C{beginning of the \\{paint} commands}\par
\P\D \37$\\{paint1}=64$\C{move right a given number of columns, then black${}%
\swap{}$white}\par
\P\D \37$\\{paint2}=65$\par
\P\D \37$\\{boc}=67$\C{beginning of a character}\par
\P\D \37$\\{boc1}=68$\C{abbreviated \\{boc}}\par
\P\D \37$\\{eoc}=69$\C{end of a character}\par
\P\D \37$\\{skip0}=70$\C{skip no blank rows}\par
\P\D \37$\\{skip1}=71$\C{skip over blank rows}\par
\P\D \37$\\{skip2}=72$\C{skip over blank rows}\par
\P\D \37$\\{new\_row\_0}=74$\C{move down one row and then right}\par
\P\D \37$\\{new\_row\_164}=238$\C{move down 164 rows and then right}\6
\C{xxx1=239 defined previously}\par
\P\D \37$\\{yyy}=243$\C{for \&{numspecial} numbers}\par
\P\D \37$\\{no\_op}=244$\C{no operation}\par
\P\D \37$\\{char\_loc}=245$\C{character locators in the postamble}\6
\C{pre=247 (preamble) defined previously}\6
\C{post 248 (postamble beginning) defined previously}\6
\C{\\{post\_post}=249 (postamble ending) defined previously}\6
\C{undefined commands==250,251,252,253,254,255}\par
\fi
\M42. The last character in a \.{GF} file is followed by `\\{post}'; this
command
introduces the postamble, which summarizes important facts that \MF\ has
accumulated. The postamble has the form
$$\vbox{\halign{\hbox{#\hfil}\cr
\\{post} $\|p[4]$ $\\{ds}[4]$ $\\{cs}[4]$ $\\{hppp}[4]$ $\\{vppp}[4]$
$\\{min\_m}[4]$ $\\{max\_m}[4]$ $\\{min\_n}[4]$ $\\{max\_n}[4]$\cr
$\langle\,$character locators$\,\rangle$\cr
\\{post\_post} $\|q[4]$ $\|i[1]$ 223's$[{\G}4]$\cr}}$$
Here \|p is a pointer to the byte following the final \\{eoc} in the file
(or to the byte following the preamble, if there are no characters);
it can be used to locate the beginning of \\{xxx} commands
that might have preceded the postamble. The \\{ds} and \\{cs} parameters
give the design size and check sum, respectively, which are exactly the
values put into the header of any \.{TFM} file that shares information with
this
\.{GF} file. Parameters \\{hppp} and \\{vppp} are the ratios of
pixels per point, horizontally and vertically, expressed as \\{scaled} integers
(i.e., multiplied by $2↑{16}$); they can be used to correlate the font
with specific device resolutions, magnifications, and ``at sizes.'' Then
come \\{min\_m}, \\{max\_m}, \\{min\_n}, and \\{max\_n}, which bound the values
that
registers \|m and~\|n assume in all characters in this \.{GF} file.
(These bounds need not be the best possible; \\{max\_m} and \\{min\_n} may, on
the
other hand, be tighter than the similar bounds in \\{boc} commands. For
example, some character may have $\\{min\_n}=-100$ in its \\{boc}, but it might
turn out that \|n never gets lower than $-50$ in any character; then
\\{min\_n} can have any value $\L-50$. If there are no characters in the file,
it's possible to have $\\{min\_m}>\\{max\_m}$ and/or $\\{min\_n}>\\{max\_n}$.)
\fi
\M43. Character locators are introduced by \\{char\_loc} commands,
which specify a character residue~\|c, character displacements ($\\{dx},%
\\{dy}$),
a character width~\|w, and a pointer~\|p
to the beginning of that character. (If two or more characters have the
same code~\|c modulo 256, only the last will be indicated; the others can be
located by following backpointers. Characters whose codes differ by a
multiple of 256 are assumed to share the same font metric information,
hence the \.{TFM} file contains only residues of character codes modulo~256.
This convention is intended for oriental languages, when there are many
character shapes but few distinct widths.)
The character displacements ($\\{dx},\\{dy}$) are the values of \MF's %
\&{chardx}
and \&{chardy} parameters; they are in units of \\{scaled} pixels;
i.e., \\{dx} is in horizontal pixel units times $2↑{16}$, and \\{dy} is in
vertical pixel units times $2↑{16}$. This is the intended amount of
displacement after typesetting the character; for \.{DVI} files, \\{dy}
should be zero, but other document file formats allow nonzero vertical
displacement.
The character width~\|w duplicates the information in the \.{TFM} file; it
is $2↑{24}$ times the ratio of the true width to the font's design size.
The backpointer \|p points to the character's \\{boc}, or to the first of
a sequence of consecutive \\{xxx} or \\{yyy} or \\{no\_op} commands that
immediately precede the \\{boc}, if such commands exist; such ``special''
commands essentially belong to the characters, while the special commands
after the final character belong to the postamble (i.e., to the font
as a whole). This convention about \|p applies also to the backpointers
in \\{boc} commands, even though it wasn't explained in the description
of~\\{boc}.
Pointer \|p might be $-1$ if the character exists in the \.{TFM} file
but not in the \.{GF} file. This unusual situation can arise in \MF\ output
if the user had $\\{proofing}<0$ when the character was being shipped out,
but then made $\\{proofing}\G0$ in order to get a \.{GF} file.
These \|p pointers are not currently being used in this program, instead we
store all rasters as received in the \\{mm\_store} and index then by
\\{glyph\_ptr}. The role of a $-1$ value for \|p is take over by a $-1$ in
the \\{glyph\_ptr} array.
\fi
\M44. The last part of the postamble, following the \\{post\_post} byte that
signifies the end of the character locators, contains \|q, a pointer to the
\\{post} command that started the postamble. An identification byte, \|i,
comes next; this currently equals~131, as in the preamble.
The \|i byte is followed by four or more bytes that are all equal to
the decimal number 223 (i.e., \O{337} in octal). \MF\ puts out four to seven of
these trailing bytes, until the total length of the file is a multiple of
four bytes, since this works out best on machines that pack four bytes per
word; but any number of 223's is allowed, as long as there are at least four
of them. In effect, 223 is a sort of signature that is added at the very end.
This curious way to finish off a \.{GF} file makes it feasible for
\.{GF}-reading programs to find the postamble first, on most computers,
even though \MF\ wants to write the postamble last. Most operating
systems permit random access to individual words or bytes of a file, so
the \.{GF} reader can start at the end and skip backwards over the 223's
until finding the identification byte. Then it can back up four bytes, read
\|q, and move to byte \|q of the file. This byte should, of course,
contain the value 248 (\\{post}); now the postamble can be read, so the
\.{GF} reader can discover all the information needed for individual
characters.
Unfortunately, however, standard \PASCAL\ does not include the ability to
access a random position in a file, or even to determine the length of a file.
Almost all systems nowadays provide the necessary capabilities, so \.{GF}
format has been designed to work most efficiently with modern operating
systems.
But if \.{GF} files have to be processed under the restrictions of standard
\PASCAL, one can simply read them from front to back. This will
be adequate for most applications. However, the postamble-first approach
would facilitate a program that merges two \.{GF} files, replacing data
from one that is overridden by corresponding data in the other.
\fi
\N45. Reading the font information.
\.{DVI} file format does not include information about character widths
nor the detailed raster information. \.{DVIIMP} gets this information
directly from the (\.{GF}) files.
The task facing \.{DVIIMP} is quite different from that facing \.{DVItype}
which has a comparatively easy task in this regard, since it needs only a
few words of information from each font. We will follow this earlier
program as much as possible in our use of file names and related details
but our data structure will necessarily be somewhat more complicated.
We follow \.{DVItype} to the extent of listing the current number of known
fonts as \\{nf}. Each known font has an internal number \|f, where $0\L\|f<%
\\{nf}$;
the external number of this font, i.e., its font identification number in
the \.{DVI} file, is $\\{font\_num}[\|f]$, and the external name of this font
is
the string that occupies positions $\\{font\_name}[\|f]$ through
$\\{font\_name}[\|f+1]-1$ of the array \\{names}. The latter array consists of
\\{ASCII\_code} characters, and $\\{font\_name}[\\{nf}]$ is its first
unoccupied
position.
Fonts cotaining more than 128 characters require special attention since
\.{Imagen} will only accept 0 to 127 as valid character numbers. An easy
way out of this difficulty is to assign \|f numbers starting at the
largest font number (95) that \.{Imagen} will accept (and progressing
downward) as \\{im\_extension} family numbers that can be assigned to the
over 127 characters of large fonts and that can be downloaded with $\|c-128$
as the \.{Imagen} identification. A record of this relationship is
maintained in an $\\{im\_extension}[\\{cur\_font}]$ array.
We will find it necessary, occasionally, to reuse the \\{mm\_store} space
and to make this possible we define a \\{free\_limit} parameter.
This parameter is set initially to \\{mm\_max}. The following
\\{make\_space} procedure is used to free space.
Note that this does not prevent the printing of those glyphs that have
been downloaded but the raster data for those glyphs that have not been
downloaded will have to be reread from the \\{gf} file should any of these
be subsequently requested.
\Y\P\4\&{procedure}\1\ \37\\{make\_space};\6
\4\&{var} \37$\|i,\39\|j,\39\|k,\39\|q$: \37\\{integer};\2\6
\&{begin} \37\&{debug} \37$\\{print}(\.{\'\ overwriting\ font\ \'})$;\5
$\\{print\_ln}(\\{font\_order}[0]:1,\39\.{\'\ \'})$;\6
\&{gubed}\6
$\|j\K\\{data\_start}[\\{font\_order}[0]]$;\5
$\|k\K\\{data\_start}[\\{font\_order}[1]]$;\5
$\|q\K\\{glyph\_ptr}[\|k]$;\6
\&{if} $\|q>12$ \1\&{then}\5
$\\{free\_limit}\K\|q-1$\6
\4\&{else} $\\{free\_limit}\K\\{mm\_size}$;\2\6
\&{for} $\|i\K\|j\mathrel{\&{to}}\|k-1$ \1\&{do}\6
\&{if} $\\{glyph\_ptr}[\|i]\G4$ \1\&{then}\5
$\\{glyph\_ptr}[\|i]\K0$;\C{mark as no longer available}\2\2\6
\&{for} $\|i\K0\mathrel{\&{to}}\\{max\_fonts}-1$ \1\&{do}\5
$\\{font\_order}[\|i]\K\\{font\_order}[\|i+1]$;\2\6
\&{end};\par
\fi
\M46. We also follow the \.{DVItype} example of storing the glyph widths
(measured in \.{DVI} units) in a \\{width} array that is indexed by values
stored in a \\{data\_base} array. This \\{data\_base} is in turn indexed by
the
internal font number and its values point to pseudo starting locations in
the \\{width} array where the first glyph widths for the fonts would be
stored were there a zero numbered glyph in the font. The actualy starting
location for each font's data in the \\{width} table is displaced forward
by \\{font\_bc} where \\{font\_bc} is the lowest character number that is
contained in each particular font. The values in the \\{data\_base} array
are, of course, also used to access the \\{pixel\_width} values (measured in
pixels) since it will be organized in an identical way to that used with
the \\{width} table.
Gaining access to the font raster details, stored in \\{mm\_store}, is a
slightly longer process because the spaces occupied by the raster details
will usually vary from glyph to glyph. We handle this matter by having
yet another indexing stage where the starting location in \\{mm\_store} for
each individual glyph is stored in a \\{glyph\_ptr} array that is accessed,
in turn, by using the same \\{data\_base} value that is used to locate the
\\{width} and \\{pixel\_width} values.
Normally, this double-indexing recall needs be done but once for
each used glyph since all glyphs are stored internally in the \.{IMAGEN}
on the first occasions when they are used. As will be noted later, we
signal the fact that any particular glyph has been down-loaded by
negating its reference number in the \\{glyph\_ptr} array.
\Y\P\D \37$\\{char\_width\_end}(\#)\S\#$ ] \par
\P\D $\\{char\_width}(\#)\S\\{width}$ [ $\\{data\_base}[\#]+\\{char\_width%
\_end}$\par
\P\D \37$\\{invalid\_width}\S\O{17777777777}$\par
\P\D \37$\\{stow}(\#)\S$\1\6
\&{begin} \37$\\{mm\_store}[\\{m1},\39\\{m2}]\K\#$;\6
\&{if} $(\\{mm}<\\{free\_limit})\W((\\{mm}+8)>\\{free\_limit})$ \1\&{then}\5
\\{make\_space};\2\6
\&{if} $\\{m2}<\\{m2\_max}$ \1\&{then}\6
\&{begin} \37$\\{incr}(\\{m2})$;\5
$\\{incr}(\\{mm})$;\6
\&{end}\6
\4\&{else} \&{begin} \37$\\{m2}\K4$;\C{$-4<\\{m2}<4$ freed for down-loading and
\\{make\_space} signs}\6
$\\{mm}\K\\{mm}+4$;\6
\&{if} $\\{m1}<\\{m1\_max}$ \1\&{then}\5
$\\{incr}(\\{m1})$\6
\4\&{else} \&{begin} \37$\\{m1}\K0$;\5
$\\{mm}\K4$;\6
\&{end};\2\6
\&{end};\2\6
\&{end}\2\par
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{font\_num}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{external font numbers}\2\6
\4\\{font\_m\_val}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{overall font magnification}\2\6
\4\\{font\_name}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
$0\to\\{name\_size}$;\C{starting positions of external font names}\2\6
\4\\{names}: \37\&{array} $[0\to\\{name\_size}]$ \1\&{of}\5
\\{ASCII\_code};\C{characters of names}\2\6
\4\\{font\_check\_sum}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{check sums}\2\6
\4\\{font\_scaled\_size}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{scale factors}\2\6
\4\\{font\_design\_size}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{design sizes}\2\6
\4\\{font\_space}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{boundary between ``small'' and ``large'' spaces}\2\6
\4\\{font\_bc}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{beginning characters in fonts}\2\6
\4\\{font\_ec}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{ending characters in fonts}\2\6
\4\\{data\_base}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{index into font data tables}\2\6
\4\\{width}: \37\&{array} $[0\to\\{max\_glyphs}]$ \1\&{of}\5
\\{integer};\C{character widths, in \.{DVI} units}\2\6
\4\\{in\_width}: \37\&{array} $[0\to255]$ \1\&{of}\5
\\{integer};\C{\.{TFM} width data in \.{DVI} units}\2\6
\4\\{tfm\_check\_sum}: \37\\{integer};\C{check sum found in \\{tfm\_file}}\6
\4\\{nf}: \37$0\to\\{max\_fonts}$;\C{the number of known fonts}\6
\4\\{nf2}: \37$0\to95$;\C{the lower limit of font extension numbers}\6
\4\\{im\_extension}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{relating extension numbers}\2\6
\4\\{width\_ptr}: \37$0\to\\{max\_glyphs}$;\C{the number of known character
widths}\6
\4$\\{bc},\39\\{ec}$: \37\\{integer};\C{beginning and ending c in current font}%
\6
\4\\{w\_byte}: \37\&{array} $[0\to\\{max\_char\_no},\390\to3]$ \1\&{of}\5
\\{eight\_bits};\C{to hold \\{width} bytes}\2\6
\4\\{gf\_ptr}: \37\&{array} $[0\to\\{max\_char\_no}]$ \1\&{of}\5
\\{integer};\C{to hold valid glyph indicators}\2\par
\fi
\M47. \P$\X11:Set initial values\X\mathrel{+}\S$\6
$\\{nf}\K0$;\5
$\\{width\_ptr}\K0$;\5
$\\{font\_name}[0]\K0$;\5
$\\{font\_space}[0]\K0$;\5
$\\{nf2}\K95$;\C{limit to usable font numbers set by Imagen}\6
\&{for} $\|i\K0\mathrel{\&{to}}\\{max\_fonts}$ \1\&{do}\5
$\\{im\_extension}[\|i]\K-1$;\C{marked as not assigned}\2\par
\fi
\M48. It is, of course, a simple matter to print the name of a given font.
\Y\P\4\&{procedure}\1\ \37$\\{print\_font}(\|f:\\{integer})$;\C{\|f is an
internal font number}\6
\4\&{var} \37\|k: \37$0\to\\{name\_size}$;\C{index into \\{names}}\2\6
\&{begin} \37\&{if} $\|f=\\{nf}$ \1\&{then}\5
$\\{print}(\.{\'UNDEFINED!\'})$\6
\4\&{else} \&{begin} \37\&{for} $\|k\K\\{font\_name}[\|f]\mathrel{\&{to}}%
\\{font\_name}[\|f+1]-1$ \1\&{do}\5
$\\{print}(\\{xchr}[\\{names}[\|k]])$;\2\6
\&{end};\2\6
\&{end};\par
\fi
\M49. The following procedure is used to print the font-name extension as
used on the \.{SAIL} computer at Stanford. It condenses a possibly 4-digit
number into three characters where the ascii characters beyond the 9
character are used, in the hundred's position, for 10, 11, etc.
\Y\P\4\&{procedure}\1\ \37$\\{print\_extension}(\|f:\\{integer})$;\C{\|f is an
internal font number}\6
\4\&{var} \37\|m: \37\\{integer};\2\6
\&{begin} \37$\|m\K\\{font\_m\_val}[\|f]$;\5
$\\{print}(\.{\'.\'})$;\5
$\\{print}(\\{xchr}[(\|m\mathbin{\&{div}}100)+\O{60}])$;\5
$\\{print}(\\{xchr}[(\|m\mathbin{\&{mod}}100)\mathbin{\&{div}}10+\O{60}])$;\5
$\\{print}(\\{xchr}[\|m\mathbin{\&{mod}}10+\O{60}])$;\6
\&{end};\par
\fi
\M50. The global variable \\{gf\_check\_sum} is set to the check sum that
appears in the current \.{GF} file.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{gf\_check\_sum}: \37\\{integer};\C{check sum found in \\{gf\_file}}\par
\fi
\M51. We will need a number of procedures to extract the necessary inforation
fron a \.{GF} file, assuming that the file has just been successfully
reset so that we are ready to read its first byte. Only a limited amount
of validity checking of the \.{GF} file will be done since \.{GF} files
are almost always valid, and since the \.{GFtype} utility program has been
specifically designed to diagnose \.{GF} errors. The procedure simply
returns \\{false} if it detects anything amiss in the \.{GF} data.
Since we are going to defer the creation of an \.{imPRESS} \\{bgly} command
for each glyph until the first time that it is actually called, we will
now only decypher the \\{gf} commands far enough to determine if they are to
be saved and to store them away in as compact a form as possible.
As mentioned earlier, raster determining commands are stored in a large
array, \\{mm\_store}. This information is stored serially, as it is received,
together with 8 bytes of preliminary information that must also be
transmitted. The location of the first byte of information is recorded
in the \\{glyph\_ptr} array. To insure that this number will always be greater
than 3 (since numbers in the range between -3 and +3 are used as special
signals) we do not use the first 4 cells in \\{mm\_store} (actually, the first
4 cells in each of the four sections into which \\{mm\_store} is divided).
Later, when the glyph is first called for
by the \.{DVI} file, we will generate an appropriate \.{IMAGEN} \\{bgly}
command and complement the pointer value in the \\{glyph\_ptr} array to show
that this has been done. Finally, as will be explained in more detail
later, we will have to arrange for the removal of the raster information
for one or more fonts, to make space for other fonts. and we will have to
store a record of this removal.
We will find it convenient to define a \\{find\_gf\_postamble} function and a
\\{read\_gf\_postamble} procedure. Since we will have occasion to deal with
parameters associated with the GF commands, we will also define a function
\\{first\_gf\_par} analogous to the \\{first\_par} that we defined earlier.
\Y\P\4\&{function}\1\ \37\\{find\_gf\_postamble}: \37\\{boolean};\6
\4\&{var} \37$\|q,\39\|k$: \37\\{integer};\2\6
\&{begin} \37$\\{find\_gf\_postamble}\K\\{true}$;\5
$\\{gf\_post\_loc}\K\\{gf\_length}-4$;\6
\1\&{repeat} \37\&{if} $\\{gf\_post\_loc}=0$ \1\&{then}\5
$\\{find\_gf\_postamble}\K\\{false}$;\2\6
$\\{move\_to\_gf\_byte}(\\{gf\_post\_loc})$;\5
$\|k\K\\{gf\_byte}$;\5
$\\{decr}(\\{gf\_post\_loc})$;\6
\4\&{until}\5
$\|k\I223$;\2\6
\&{if} $\|k\I\\{gf\_id\_byte}$ \1\&{then}\5
$\\{find\_gf\_postamble}\K\\{false}$;\2\6
$\\{move\_to\_gf\_byte}(\\{gf\_post\_loc}-3)$;\5
$\|q\K\\{gf\_signed\_quad}$;\6
\&{if} $(\|q<0)\V(\|q>\\{gf\_post\_loc}-3)$ \1\&{then}\5
$\\{find\_gf\_postamble}\K\\{false}$;\2\6
$\\{move\_to\_gf\_byte}(\|q)$;\5
$\|k\K\\{gf\_byte}$;\6
\&{if} $\|k\I\\{post}$ \1\&{then}\5
$\\{find\_gf\_postamble}\K\\{false}$;\2\6
\&{debug} \37$\\{print\_ln}(\.{\'\ gf\ postamble\ at\ \'},\39\\{cur\_gf%
\_loc}:1)$;\6
\&{gubed}\6
\&{end};\par
\fi
\M52. Having found the \\{gf\_postamble}, we must now read it and stow the
data away as as halfwords as required later by \.{IMAGEN}.
\Y\P\4\&{procedure}\1\ \37\\{read\_gf\_postamble};\6
\4\&{var} \37$\|k,\39\|l$: \37\\{integer};\C{loop indices}\6
$\|p,\39\|q,\39\|m,\39\|c$: \37\\{integer};\C{general purpose registers}\2\6
\&{begin} \37$\\{gf\_post\_loc}\K\\{cur\_gf\_loc}-1$;\5
$\|p\K\\{gf\_signed\_quad}$;\5
$\\{design\_size}\K\\{gf\_signed\_quad}$;\5
$\\{check\_sum}\K\\{gf\_signed\_quad}$;\6
$\\{hppp}\K\\{gf\_signed\_quad}$;\5
$\\{vppp}\K\\{gf\_signed\_quad}$;\6
$\\{magnification}\K\\{hppp}/(65536.0\ast\\{resolution}/72.27)$;\5
$\\{min\_m}\K\\{gf\_signed\_quad}$;\5
$\\{max\_m}\K\\{gf\_signed\_quad}$;\5
$\\{min\_n}\K\\{gf\_signed\_quad}$;\5
$\\{max\_n}\K\\{gf\_signed\_quad}$;\6
$\\{bc}\K\\{max\_char\_no}$;\5
$\\{ec}\K0$;\C{prepare for a determination in Process the character loc}\6
\X53:Clear \\{w\_byte} array\X;\6
\X54:Process the character locations in the postamble\X;\6
\&{while} $\R\\{eof}(\\{gf\_file})$ \1\&{do}\5
$\|m\K\\{gf\_byte}$;\C{to close out file}\2\6
\&{end};\7
\4\&{function}\1\ \37$\\{first\_gf\_par}(\|o:\\{eight\_bits})$: \37%
\\{integer};\2\6
\&{begin} \37\&{case} $\|o$ \1\&{of}\6
\4$\\{sixty\_four\_cases}(\\{paint\_0})$: \37$\\{first\_gf\_par}\K\|o-\\{paint%
\_0}$;\6
\4$\\{paint1},\39\\{skip1},\39\\{char\_loc},\39\\{char\_loc}+1,\39\\{xxx1}$: %
\37$\\{first\_gf\_par}\K\\{gf\_byte}$;\6
\4$\\{paint2},\39\\{skip2},\39\\{xxx1}+1$: \37$\\{first\_gf\_par}\K\\{gf\_two%
\_bytes}$;\6
\4$\\{paint1}+2,\39\\{skip1}+2,\39\\{xxx1}+2$: \37$\\{first\_gf\_par}\K\\{gf%
\_three\_bytes}$;\6
\4$\\{xxx1}+3,\39\\{yyy}$: \37$\\{first\_gf\_par}\K\\{gf\_signed\_quad}$;\6
\4$\\{boc},\39\\{boc1},\39\\{eoc},\39\\{skip0},\39\\{no\_op},\39\\{pre},\39%
\\{post},\39\\{post\_post},\39\\{undefined\_commands}$: \37$\\{first\_gf\_par}%
\K0$;\6
\4$\\{one\_sixty\_five\_cases}(\\{new\_row\_0})$: \37$\\{first\_gf\_par}\K\|o-%
\\{new\_row\_0}$;\2\6
\&{end};\6
\&{end};\7
\4\&{procedure}\1\ \37\\{copy\_byte};\6
\4\&{var} \37\|w: \37\\{eight\_bits};\2\6
\&{begin} \37$\|w\K\\{gf\_byte}$;\5
$\\{stow}(\|w)$;\6
\&{end};\7
\4\&{procedure}\1\ \37$\\{stow\_pair}(\|w:\\{integer})$;\2\6
\&{begin} \37$\\{stow}(\|w\mathbin{\&{div}}\H{100})$;\5
$\\{stow}(\|w\mathbin{\&{mod}}\H{100})$;\6
\&{end};\7
\4\&{procedure}\1\ \37$\\{stow\_signed\_pair}(\|w:\\{integer})$;\2\6
\&{begin} \37\&{if} $\|w<0$ \1\&{then}\5
$\|w\K\|w+\H{10000}$;\2\6
$\\{stow}(\|w\mathbin{\&{div}}\H{100})$;\5
$\\{stow}(\|w\mathbin{\&{mod}}\H{100})$;\6
\&{end};\par
\fi
\M53. \P$\X53:Clear \\{w\_byte} array\X\S$\6
\&{for} $\|k\K0\mathrel{\&{to}}\\{max\_char\_no}$ \1\&{do}\6
\&{begin} \37\&{for} $\|l\K0\mathrel{\&{to}}3$ \1\&{do}\5
$\\{w\_byte}[\|k,\39\|l]\K0$;\2\6
$\\{gf\_ptr}[\|k]\K0$;\C{so data of missing glyphs will be made available}\6
\&{end};\2\par
\U section~52.\fi
\M54. \P$\X54:Process the character locations in the postamble\X\S$\6
\1\&{repeat} \37$\|k\K\\{gf\_byte}$;\6
\&{if} $(\|k=\\{char\_loc})\V(\|k=\\{char\_loc}+1)$ \1\&{then}\6
\&{begin} \37$\|c\K\\{gf\_byte}$;\6
\&{if} $\|c>\\{max\_char\_no}$ \1\&{then}\5
$\\{abort}(\.{\'Character\ number\ too\ large\'})$;\2\6
\&{if} $\|c<\\{bc}$ \1\&{then}\5
$\\{bc}\K\|c$;\2\6
\&{if} $\|c>\\{ec}$ \1\&{then}\5
$\\{ec}\K\|c$;\2\6
\&{if} $\|k=\\{char\_loc}$ \1\&{then}\6
\&{begin} \37$\\{dx}[\|c]\K\\{gf\_signed\_quad}\mathbin{\&{div}}65536$;\5
$\\{dy}\K\\{gf\_signed\_quad}$;\6
\&{end}\6
\4\&{else} \&{begin} \37$\\{dx}[\|c]\K\\{gf\_byte}$;\5
$\\{dy}\K0$;\6
\&{end};\2\6
\&{debug} \37$\\{print}(\.{\'\ k=\'},\39\|k:1,\39\.{\'\ c=\'},\39\|c:1,\39\.{\'%
\ dx=\'},\39\\{dx}[\|c]:1)$;\6
\&{gubed}\6
$\\{w\_byte}[\|c,\390]\K\\{gf\_byte}$;\5
$\\{w\_byte}[\|c,\391]\K\\{gf\_byte}$;\5
$\\{w\_byte}[\|c,\392]\K\\{gf\_byte}$;\5
$\\{w\_byte}[\|c,\393]\K\\{gf\_byte}$;\5
$\\{gf\_ptr}[\|c]\K\\{gf\_signed\_quad}$;\C{the $>0$ values will mark existing
glyphs}\6
\&{debug} \37$\\{print\_ln}(\.{\'\ k=\'},\39\|k:1,\39\.{\'\ gfptr=\'},\39\\{gf%
\_ptr}[\|c]:1)$;\6
\&{gubed}\6
$\|k\K\\{no\_op}$;\6
\&{end};\2\6
\4\&{until}\5
$\|k\I\\{no\_op}$;\2\par
\U section~52.\fi
\M55. Here is the main information we glean from the postamble together with
some auxiliary parameters.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{design\_size}: \37\\{integer};\6
\4$\\{hppp},\39\\{vppp}$: \37\\{integer};\6
\4\\{check\_sum}: \37\\{integer};\6
\4\\{gf\_post\_loc}: \37\\{integer};\6
\4\\{magnification}: \37\\{real};\6
\4\\{dx}: \37\&{array} $[0\to\\{max\_char\_no}]$ \1\&{of}\5
\\{integer};\2\6
\4\\{dy}: \37\\{integer};\C{not used since value should always be zero}\6
\4\\{total\_glyphs}: \37\\{integer};\C{the total number of glyphs stored in %
\\{mm\_store}}\6
\4\\{mm\_store}: \37\&{packed} \37\&{array} $[0\to\\{m1\_max},\394\to\\{m2%
\_max}]$ \1\&{of}\5
\\{eight\_bits};\C{to store glyph information}\2\6
\4$\\{mm},\39\\{m1},\39\\{m2}$: \37\\{integer};\C{indices for \\{mm\_store}}\6
\4\\{free\_limit}: \37\\{integer};\C{\\{mm} value of last free location in %
\\{mm\_store}}\6
\4\\{data\_start}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{$\\{data\_base}+\\{bc}$ for fonts}\2\6
\4\\{font\_order}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{font numbers in loaded order}\2\6
\4\\{gf\_prev\_ptr}: \37\\{integer};\C{location of next character}\6
\4\\{char\_code}: \37\\{integer};\C{current character number}\6
\4\\{glyph\_ptr}: \37\&{array} $[0\to\\{max\_glyphs}]$ \1\&{of}\5
\\{integer};\C{pointers to \\{mm\_store}}\2\6
\4$\\{max\_m},\39\\{min\_m},\39\\{max\_n},\39\\{min\_n}$: \37\\{integer};%
\C{raster bounding parameters}\6
\4\\{row\_count}: \37\\{integer};\C{used to correct the raster height figure}\6
\4\\{column\_count}: \37\\{integer};\C{used to accumulate column counts}\6
\4\\{max\_column\_count}: \37\\{integer};\C{used to correct the raster width
figure}\par
\fi
\M56. \P$\X11:Set initial values\X\mathrel{+}\S$\6
\&{for} $\|i\K0\mathrel{\&{to}}\\{max\_glyphs}$ \1\&{do}\5
$\\{glyph\_ptr}[\|i]\K-1$;\C{mark glyphs as not being in the file}\2\6
$\\{total\_glyphs}\K0$;\5
$\\{mm}\K4$;\5
$\\{m1}\K0$;\5
$\\{m2}\K4$;\C{$-4<\\{mm}<4$ saved for signalling purposes}\6
$\\{free\_limit}\K\\{mm\_max}$;\6
\&{for} $\|i\K0\mathrel{\&{to}}\\{max\_fonts}$ \1\&{do}\5
$\\{font\_order}[\|i]\K-1$;\2\par
\fi
\M57. A temporary procedure.
\Y\P\&{debug} \37\&{procedure}\1\ \37\\{tabulate};\6
\4\&{var} \37$\|i,\39\|j,\39\|k,\39\|l$: \37\\{integer};\2\6
\&{begin} \37$\\{print\_ln}(\.{\'\'})$;\5
$\\{print\_ln}(\.{\'\ \ Contents\ of\ the\ glyph\ ptr\ table\'})$;\5
$\\{print}(\.{\'\ \ \ \ \ \'})$;\6
\&{for} $\|j\K0\mathrel{\&{to}}9$ \1\&{do}\5
$\\{print}(\|j:7)$;\2\6
$\\{print\_ln}(\.{\'\'})$;\6
\&{for} $\|i\K0\mathrel{\&{to}}29$ \1\&{do}\6
\&{begin} \37$\\{print}(\|i\ast10:3,\39\.{\'\ \'})$;\6
\&{for} $\|j\K0\mathrel{\&{to}}9$ \1\&{do}\6
\&{begin} \37$\|k\K\\{glyph\_ptr}[10\ast\|i+\|j]$;\5
$\|l\K\|k\mathbin{\&{div}}\\{m2\_size}$;\5
$\|k\K\|k\mathbin{\&{mod}}\\{m2\_size}$;\5
$\\{print}(\|l:1,\39\.{\',\'},\39\|k:1)$;\6
\&{end};\2\6
$\\{print\_ln}(\.{\'\'})$;\6
\&{end};\2\6
\&{end};\6
\&{gubed}\par
\fi
\M58. Here is the long awaited \\{in\_gf} routine.
\Y\P\4\&{function}\1\ \37$\\{in\_gf}(\|z:\\{integer})$: \37\\{boolean};%
\C{input \.{GF} data or return \\{false}}\6
\4\&{label} \37$\\{done},\39\\{restart},\399997,\39$\C{go here when the format
is bad}\6
$9998,\39$\C{go here when the information cannot be loaded}\6
9999;\C{go here to exit}\6
\4\&{var} \37\|k: \37\\{integer};\C{index for loops}\6
\\{lh}: \37\\{integer};\C{length of the header data, in four-byte words}\6
\\{nw}: \37\\{integer};\C{number of words in the width table}\6
\\{wp}: \37$0\to\\{max\_glyphs}$;\C{new value of \\{width\_ptr} after
successful input}\6
$\\{alpha},\39\\{beta}$: \37\\{integer};\C{quantities used in the scaling
computation}\6
\|c: \37\\{integer};\C{ used it index character number}\6
\|o: \37\\{integer};\C{used to hold \\{gf} commands}\6
\|p: \37\\{integer};\C{used to hold \\{gf} parameter}\6
\\{del\_m}: \37\\{integer};\C{used to hold \\{gf} parameter}\6
\\{del\_n}: \37\\{integer};\C{used to hold \\{gf} parameter}\6
$\\{mm\_save},\39\\{m1\_save},\39\\{m2\_save}$: \37\\{integer};\C{temp save to
allow for corrections}\2\6
\&{begin} \37\&{if} $\R\\{find\_gf\_postamble}$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'\ Trouble\ with\ postamble\'})$;\5
\&{goto} \379997;\6
\&{end};\2\6
\\{read\_gf\_postamble};\5
\X59:Check \\{width} table and \&{goto} 9997 if there is a problem\X;\6
\X62:Convert and store the width values\X;\6
\X60:Process the gf preamble\X;\6
\X69:Stow all of the glyph-raster info\X;\6
\&{debug} \37\\{tabulate};\C{Used to show the start of the \\{glyph\_ptr}
array}\6
$\\{print\_ln}(\.{\'\ glyph-raster\ done\'})$;\6
\&{gubed}\6
$\\{width\_ptr}\K\\{wp}$;\5
$\\{in\_gf}\K\\{true}$;\5
\&{goto} \379999;\6
\49997: \37$\\{print\_ln}(\.{\'---not\ loaded,\ GF\ file\ is\ bad\'})$;\6
\49998: \37$\\{in\_gf}\K\\{false}$;\6
\49999: \37\&{end};\par
\fi
\M59. \P$\X59:Check \\{width} table and \&{goto} 9997 if there is a problem\X%
\S$\6
$\\{font\_bc}[\\{cur\_font}]\K\\{bc}$;\5
$\\{font\_ec}[\\{cur\_font}]\K\\{ec}$;\6
\&{if} $\\{font\_ec}[\\{cur\_font}]<\\{font\_bc}[\\{cur\_font}]$ \1\&{then}\5
$\\{font\_bc}[\\{cur\_font}]\K\\{font\_ec}[\\{cur\_font}]+1$;\2\6
\&{if} $\\{width\_ptr}+\\{font\_ec}[\\{cur\_font}]-\\{font\_bc}[\\{cur%
\_font}]+1>\\{max\_glyphs}$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'---not\ loaded,\ DVIIMP\ needs\ larger\ width\
table\'})$;\5
\&{goto} \379998;\6
\&{end};\2\6
$\\{wp}\K\\{width\_ptr}+\\{font\_ec}[\\{cur\_font}]-\\{font\_bc}[\\{cur%
\_font}]+1$;\5
$\\{nw}\K\\{ec}+1-\\{bc}$;\6
\&{debug} \37$\\{print\_ln}(\.{\'\ bc=\'},\39\\{bc}:1,\39\.{\'\ ec=\'},\39%
\\{ec}:1,\39\.{\'\ nw=\'},\39\\{nw}:1)$;\6
\&{gubed}\6
\&{if} $(\\{nw}=0)\V(\\{nw}>256)$ \1\&{then}\5
\&{goto} \379997;\2\par
\U section~58.\fi
\M60. \P$\X60:Process the gf preamble\X\S$\6
\\{open\_gf\_file};\5
$\|o\K\\{gf\_byte}$;\C{fetch the first byte}\6
\&{if} $\|o\I\\{pre}$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'\ GF\ file\ does\ not\ start\ with\ |pre|%
\'})$;\5
\&{goto} \379997;\6
\&{end};\2\6
$\|o\K\\{gf\_byte}$;\C{fetch the identification byte}\6
\&{if} $\|o\I\\{gf\_id\_byte}$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'\ id\ =\'},\39\|o:1,\39\.{\'\ should\ be\ \'},%
\39\\{gf\_id\_byte}:1)$;\5
\&{goto} \379997;\6
\&{end};\2\6
$\|o\K\\{gf\_byte}$;\C{fetch the length of the introductory comment}\6
\&{while} $\|o>0$ \1\&{do}\6
\&{begin} \37$\\{decr}(\|o)$;\5
$\|p\K\\{gf\_byte}$;\6
\&{end};\2\par
\U section~58.\fi
\M61. An important part of \\{in\_gf} is the width computation, which
involves multiplying the relative widths in the \.{GF} file by the
scaling factor in the \.{DVI} file. This fixed-point multiplication
must be done with precisely the same accuracy by all \.{DVI}-reading programs,
in order to validate the assumptions made by \.{DVI}-writing programs
like \TeX82.
Let us therefore summarize what needs to be done. Each width in a \.{GF}
file appears as a four-byte quantity called a \\{fix\_word}. A \\{fix\_word}
whose respective bytes are $(a,b,c,d)$ represents the number
$$x=\left\{\vcenter{\halign{$#$,\hfil\qquad&if $#$\hfil\cr
b\cdot2↑{-4}+c\cdot2↑{-12}+d\cdot2↑{-20}&a=0;\cr
-16+b\cdot2↑{-4}+c\cdot2↑{-12}+d\cdot2↑{-20}&a=255.\cr}}\right.$$
(No other choices of $a$ are allowed, since the magnitude of a \.{GF}
dimension must be less than 16.) We want to multiply this quantity by the
integer~\|z, which is known to be less than $2↑{27}$. Let $\alpha=16z$.
If $\|z<2↑{23}$, the individual multiplications $b\cdot z$, $c\cdot z$,
$d\cdot z$ cannot overflow; otherwise we will divide \|z by 2, 4, 8, or
16, to obtain a multiplier less than $2↑{23}$, and we can compensate for
this later. If \|z has thereby been replaced by $\|z↑\prime=\|z/2↑e$, let
$\beta=2↑{4-e}$; we shall compute
$$\lfloor(b+c\cdot2↑{-8}+d\cdot2↑{-16})\,z↑\prime/\beta\rfloor$$ if $a=0$,
or the same quantity minus $\alpha$ if $a=255$. This calculation must be
done exactly, for the reasons stated above; the following program does the
job in a system-independent way, assuming that arithmetic is exact on
numbers less than $2↑{31}$ in magnitude.
Whereas \.{DVItype} obtained the \\{pixel\_width}s by rounding the \\{width}
value, we obtain these values from the \\{dx} parameter associated with the
\\{char\_loc} command. It should be noted that $\\{width}[\|k]$ is the
device-independent width of some character in \.{DVI} units while
$\\{pixel\_width}[\|k]$ is the corresponding pixel width of that character in
an
actual font.
The macro \\{char\_pixel\_width} is set up to be analogous to \\{char\_width}.
\Y\P\D $\\{char\_pixel\_width}(\#)\S\\{pixel\_width}$ [ $\\{data\_base}[\#]+%
\\{char\_width\_end}$\par
\P\D \37$\\{pixel\_round}(\#)\S\\{round}(\\{conv}\ast(\#))$\par
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{pixel\_width}: \37\&{array} $[0\to\\{max\_glyphs}]$ \1\&{of}\5
\\{integer};\C{actual character widths, in pixels}\2\6
\4\\{conv}: \37\\{real};\C{converts \.{DVI} units to pixels}\6
\4\\{true\_conv}: \37\\{real};\C{converts unmagnified \.{DVI} units to pixels}\6
\4$\\{numerator},\39\\{denominator}$: \37\\{integer};\C{stated conversion
ratio}\6
\4\\{mag}: \37\\{integer};\C{magnification factor times 1000}\6
\4\\{empty\_glyph}: \37\\{boolean};\C{foxing Imagen into accepting an empty
glyph}\par
\fi
\M62. \P$\X62:Convert and store the width values\X\S$\6
\X63:Replace \|z by $\|z↑\prime$ and compute $\alpha,\beta$\X;\6
$\\{data\_base}[\\{cur\_font}]\K\\{width\_ptr}-\\{bc}$;\5
$\\{data\_start}[\\{cur\_font}]\K\\{width\_ptr}$;\5
$\\{wp}\K\\{width\_ptr}+\\{ec}-\\{bc}+1$;\5
$\|c\K\\{bc}$;\6
\&{for} $\|k\K\\{width\_ptr}\mathrel{\&{to}}\\{wp}-1$ \1\&{do}\6
\&{begin} \37\&{if} $\\{gf\_ptr}[\|c]=0$ \1\&{then}\6
\&{begin} \37$\\{width}[\|k]\K\\{invalid\_width}$;\5
$\\{pixel\_width}[\|k]\K0$;\6
\&{debug} \37$\\{print}(\.{\'\ invalid\ width\ for\ c=\'},\39\|c:1)$;\6
\&{gubed}\6
\&{end}\6
\4\&{else} \&{begin} \37$\\{width}[\|k]\K(((((\\{w\_byte}[\|c,\393]\ast\|z)%
\mathbin{\&{div}}\O{400})+(\\{w\_byte}[\|c,\392]\ast\|z))\mathbin{\&{div}}%
\O{400})+(\\{w\_byte}[\|c,\391]\ast\|z))\mathbin{\&{div}}\\{beta}$;\6
\&{if} $(\\{w\_byte}[\|c,\390]>0)$ \1\&{then}\6
\&{if} $(\\{w\_byte}[\|c,\390]<255)$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'\ w\ byte=\'},\39\\{w\_byte}[\|c,\390]:1)$;\5
\&{goto} \379997\6
\&{end}\6
\4\&{else} $\\{width}[\|k]\K\\{width}[\|k]-\\{alpha}$;\2\2\6
$\\{pixel\_width}[\|k]\K\\{dx}[\|c]$;\6
\&{end};\2\6
\&{debug} \37$\\{print}(\.{\'\ dx=\'},\39\\{dx}[\|c]:1,\39\.{\'\ for\ \'},\39%
\|c:1)$;\5
$\\{print}(\.{\'\ [\ \'},\39\|c:1,\39\.{\']\'})$;\6
\&{gubed}\6
$\\{incr}(\|c)$;\6
\&{end};\2\par
\U section~58.\fi
\M63. \P$\X63:Replace \|z by $\|z↑\prime$ and compute $\alpha,\beta$\X\S$\6
\&{begin} \37$\\{alpha}\K16\ast\|z$;\5
$\\{beta}\K16$;\6
\&{while} $\|z\G\O{40000000}$ \1\&{do}\6
\&{begin} \37$\|z\K\|z\mathbin{\&{div}}2$;\5
$\\{beta}\K\\{beta}\mathbin{\&{div}}2$;\6
\&{end};\2\6
\&{end}\par
\U sections~62 and~67.\fi
\M64. In those few cases (we hope) where a \.{GF} file is not available we
will want to refer to the \.{TFM} file and leave space in the document for
the missing glyphs. The following procedure is used for this purpose.
\Y\P\4\&{function}\1\ \37$\\{in\_tfm}(\|z:\\{integer})$: \37\\{boolean};%
\C{input \.{TFM} data or return \\{false}}\6
\4\&{label} \37$9997,\39$\C{go here when the format is bad}\6
$9998,\39$\C{go here when the information cannot be loaded}\6
9999;\C{go here to exit}\6
\4\&{var} \37\|k: \37\\{integer};\C{index for loops}\6
\\{lh}: \37\\{integer};\C{length of the header data, in four-byte words}\6
\\{nw}: \37\\{integer};\C{number of words in the width table}\6
\\{wp}: \37$0\to\\{max\_glyphs}$;\C{new value of \\{width\_ptr} after
successful input}\6
$\\{alpha},\39\\{beta}$: \37\\{integer};\C{quantities used in the scaling
computation}\2\6
\&{begin} \37\X65:Read past the header data; \&{goto} 9997 if there is a
problem\X;\6
\X66:Store character-width indices at the end of the \\{width} table\X;\6
\X67:Read and convert the width values, setting up the \\{in\_width} table\X;\6
\X68:Move the widths from \\{in\_width} to \\{width}, and append \\{pixel%
\_width} values\X;\6
$\\{width\_ptr}\K\\{wp}$;\5
$\\{in\_tfm}\K\\{true}$;\5
\&{goto} \379999;\6
\49997: \37$\\{print\_ln}(\.{\'---not\ loaded,\ TFM\ file\ is\ bad\'})$;\6
\49998: \37$\\{in\_tfm}\K\\{false}$;\6
\49999: \37\&{end};\par
\fi
\M65. \P$\X65:Read past the header data; \&{goto} 9997 if there is a problem\X%
\S$\6
\\{read\_tfm\_word};\5
$\\{lh}\K\\{b2}\ast256+\\{b3}$;\5
\\{read\_tfm\_word};\5
$\\{font\_bc}[\\{cur\_font}]\K\\{b0}\ast256+\\{b1}$;\5
$\\{font\_ec}[\\{cur\_font}]\K\\{b2}\ast256+\\{b3}$;\6
\&{if} $\\{font\_ec}[\\{cur\_font}]<\\{font\_bc}[\\{cur\_font}]$ \1\&{then}\5
$\\{font\_bc}[\\{cur\_font}]\K\\{font\_ec}[\\{cur\_font}]+1$;\2\6
\&{if} $\\{width\_ptr}+\\{font\_ec}[\\{cur\_font}]-\\{font\_bc}[\\{cur%
\_font}]+1>\\{max\_glyphs}$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'---not\ loaded,\ DVItype\ needs\ larger\ width%
\ table\'})$;\5
\&{goto} \379998;\6
\&{end};\2\6
$\\{wp}\K\\{width\_ptr}+\\{font\_ec}[\\{cur\_font}]-\\{font\_bc}[\\{cur%
\_font}]+1$;\5
\\{read\_tfm\_word};\5
$\\{nw}\K\\{b0}\ast256+\\{b1}$;\6
\&{if} $(\\{nw}=0)\V(\\{nw}>256)$ \1\&{then}\5
\&{goto} \379997;\2\6
\&{for} $\|k\K1\mathrel{\&{to}}3+\\{lh}$ \1\&{do}\6
\&{begin} \37\&{if} $\\{eof}(\\{tfm\_file})$ \1\&{then}\5
\&{goto} \379997;\2\6
\\{read\_tfm\_word};\6
\&{if} $\|k=4$ \1\&{then}\6
\&{if} $\\{b0}<128$ \1\&{then}\5
$\\{tfm\_check\_sum}\K((\\{b0}\ast256+\\{b1})\ast256+\\{b2})\ast256+\\{b3}$\6
\4\&{else} $\\{tfm\_check\_sum}\K(((\\{b0}-256)\ast256+\\{b1})\ast256+\\{b2})%
\ast256+\\{b3}$;\2\2\6
\&{end};\2\par
\U section~64.\fi
\M66. \P$\X66:Store character-width indices at the end of the \\{width} table\X%
\S$\6
\&{if} $\\{wp}>0$ \1\&{then}\6
\&{for} $\|k\K\\{width\_ptr}\mathrel{\&{to}}\\{wp}-1$ \1\&{do}\6
\&{begin} \37\\{read\_tfm\_word};\6
\&{if} $\\{b0}>\\{nw}$ \1\&{then}\5
\&{goto} \379997;\2\6
$\\{width}[\|k]\K\\{b0}$;\6
\&{end};\2\2\par
\U section~64.\fi
\M67. \P$\X67:Read and convert the width values, setting up the \\{in\_width}
table\X\S$\6
\X63:Replace \|z by $\|z↑\prime$ and compute $\alpha,\beta$\X;\6
\&{for} $\|k\K0\mathrel{\&{to}}\\{nw}-1$ \1\&{do}\6
\&{begin} \37\\{read\_tfm\_word};\5
$\\{in\_width}[\|k]\K(((((\\{b3}\ast\|z)\mathbin{\&{div}}\O{400})+(\\{b2}\ast%
\|z))\mathbin{\&{div}}\O{400})+(\\{b1}\ast\|z))\mathbin{\&{div}}\\{beta}$;\6
\&{if} $\\{b0}>0$ \1\&{then}\6
\&{if} $\\{b0}<255$ \1\&{then}\5
\&{goto} \379997\6
\4\&{else} $\\{in\_width}[\|k]\K\\{in\_width}[\|k]-\\{alpha}$;\2\2\6
\&{end}\2\par
\U section~64.\fi
\M68. \P$\X68:Move the widths from \\{in\_width} to \\{width}, and append %
\\{pixel\_width} values\X\S$\6
\&{if} $\\{in\_width}[0]\I0$ \1\&{then}\5
\&{goto} \379997;\C{the first width should be zero}\2\6
$\\{data\_base}[\\{cur\_font}]\K\\{width\_ptr}-\\{font\_bc}[\\{cur\_font}]$;\6
\&{if} $\\{wp}>0$ \1\&{then}\6
\&{for} $\|k\K\\{width\_ptr}\mathrel{\&{to}}\\{wp}-1$ \1\&{do}\6
\&{if} $\\{width}[\|k]=0$ \1\&{then}\6
\&{begin} \37$\\{width}[\|k]\K\\{invalid\_width}$;\5
$\\{pixel\_width}[\|k]\K0$;\6
\&{end}\6
\4\&{else} \&{begin} \37$\\{width}[\|k]\K\\{in\_width}[\\{width}[\|k]]$;\5
$\\{pixel\_width}[\|k]\K\\{pixel\_round}(\\{width}[\|k])$;\5
$\\{glyph\_ptr}[\|k]\K-1$;\6
\&{end}\2\2\2\par
\U section~64.\fi
\M69. \P$\X69:Stow all of the glyph-raster info\X\S$\6
\&{debug} \37$\\{print\_ln}(\.{\'\ loading\ font\ \ \'},\39\\{cur\_font}:1,\39%
\.{\'[\'},\39\\{m1}:1,\39\.{\',\'},\39\\{m2}:1,\39\.{\']\ \'})$;\5
$\\{print}((\\{free\_limit}\mathbin{\&{div}}\\{m2\_size}):1,\39\.{\'-\'},\39(%
\\{free\_limit}\mathbin{\&{mod}}\\{m2\_size}):1,\39\.{\'\ \'})$;\6
\&{gubed}\6
$\|k\K0$;\6
\&{while} $\\{font\_order}[\|k]\G0$ \1\&{do}\5
$\\{incr}(\|k)$;\2\6
$\\{font\_order}[\|k]\K\\{cur\_font}$;\C{add this font to ordered list}\6
\1\&{repeat} \37$\\{gf\_prev\_ptr}\K\\{cur\_gf\_loc}$;\5
\X75:Pass \\{no\_op}, \\{xxx} and \\{yyy} commands\X;\6
\&{if} $(\|o=\\{boc})\V(\|o=\\{boc1})$ \1\&{then}\6
\&{begin} \37$\\{m1\_save}\K\\{m1}$;\5
$\\{m2\_save}\K\\{m2}$;\C{for width and height corrections}\6
$\\{mm\_save}\K\\{m1}\ast\\{m2\_size}+\\{m2}$;\C{to be stored in \\{glyph\_ptr}
when \|c is known}\6
\&{if} $\|o=\\{boc}$ \1\&{then}\6
\&{begin} \37\X71:Stow the \\{boc} information\X\6
\&{end}\6
\4\&{else} \&{begin} \37\X73:Stow the \\{boc1} information\X;\6
\&{end};\2\6
$\\{glyph\_ptr}[\\{data\_base}[\\{cur\_font}]+\|c]\K\\{mm\_save}$;\C{save glyph
start address}\6
\&{debug} \37$\\{print}(\.{\'\ (\'},\39\\{cur\_font}:1,\39\.{\')\'},\39\|c:1,%
\39\.{\'[\'},\39\\{m1}:1,\39\.{\',\'},\39\\{m2}:1,\39\.{\']\'})$;\6
\&{gubed}\6
\&{if} $\\{empty\_glyph}$ \1\&{then}\6
\&{begin} \37$\\{glyph\_ptr}[\\{data\_base}[\\{cur\_font}]+\|c]\K-1$;\5
$\\{empty\_glyph}\K\\{false}$;\6
\&{end};\2\6
\X76:Stow the glyph details\X;\6
\&{end};\2\6
\4\&{until}\5
$\|o=\\{post}$;\2\par
\U section~58.\fi
\M70. As noted earlier, the parameters associated with the \\{boc} command are
received from the \\{gf} file as \\{signed\_quad}s and are converted into the
form needed by the \.{IMAGEN} and then stowed into \\{mm\_store} as
\\{signed\_pairs}, in keeping with the restricted range of value that the
\.{IMAGEN} allows.
\fi
\M71. \P$\X71:Stow the \\{boc} information\X\S$\6
$\\{incr}(\\{total\_glyphs})$;\5
$\\{char\_code}\K\\{gf\_signed\_quad}$;\5
$\|p\K\\{gf\_signed\_quad}$;\5
$\|c\K\\{char\_code}\mathbin{\&{mod}}256$;\6
\&{if} $\|c<0$ \1\&{then}\5
$\|c\K\|c+256$;\2\6
\&{if} $\|c>127$ \1\&{then}\6
\&{if} $\\{im\_extension}[\\{cur\_font}]=-1$ \1\&{then}\6
\&{begin} \37\&{if} $\\{nf2}=\\{nf}$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'\ ---Out\ of\ font\ storage\ space\'})$;\5
\&{goto} \379998;\6
\&{end};\2\6
$\\{im\_extension}[\\{cur\_font}]\K\\{nf2}$;\5
$\\{decr}(\\{nf2})$;\6
\&{end};\2\2\6
\&{debug} \37$\\{print}(\.{\'\ boc[\'},\39\|c:1,\39\.{\']\'})$;\6
\&{if} $\\{char\_code}\I\|c$ \1\&{then}\5
$\\{print}(\.{\'\ in\ family\ \'},\39(\\{char\_code}-\|c)\mathbin{%
\&{div}}256:1)$;\2\6
\&{gubed}\6
$\\{min\_m}\K\\{gf\_signed\_quad}$;\5
$\\{max\_m}\K\\{gf\_signed\_quad}$;\5
$\\{min\_n}\K\\{gf\_signed\_quad}$;\5
$\\{max\_n}\K\\{gf\_signed\_quad}$;\6
\&{if} $\\{max\_m}-\\{min\_m}\L0$ \1\&{then}\5
$\\{empty\_glyph}\K\\{true}$\6
\4\&{else} $\\{empty\_glyph}\K\\{false}$;\2\6
$\\{stow\_signed\_pair}(\\{max\_m}-\\{min\_m}+1)$;\C{width}\6
$\\{stow\_signed\_pair}(-\\{min\_m})$;\C{left offset}\6
$\\{stow\_signed\_pair}(\\{max\_n}-\\{min\_n}+1)$;\C{height}\6
$\\{stow\_signed\_pair}(\\{max\_n})$;\C{top offset}\par
\U section~69.\fi
\M72. Similarly, the one byte parameters associated with the
\\{boc1} command are converted into the required form and stored into
\\{mm\_store} as \\{signed\_pairs}.
\fi
\M73. \P$\X73:Stow the \\{boc1} information\X\S$\6
$\\{incr}(\\{total\_glyphs})$;\5
$\\{char\_code}\K\\{gf\_byte}$;\5
$\|p\K-1$;\5
$\|c\K\\{char\_code}$;\6
\&{if} $\|c>127$ \1\&{then}\6
\&{if} $\\{im\_extension}[\\{cur\_font}]=-1$ \1\&{then}\6
\&{begin} \37\&{if} $\\{nf2}=\\{nf}$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'\ ---Out\ of\ font\ storage\ space\'})$;\5
\&{goto} \379998;\6
\&{end};\2\6
$\\{im\_extension}[\\{cur\_font}]\K\\{nf2}$;\5
$\\{decr}(\\{nf2})$;\6
\&{end};\2\2\6
\&{debug} \37$\\{print\_ln}(\.{\'\'})$;\5
$\\{print\_ln}(\.{\'\'})$;\5
$\\{print}(\.{\'\ boc1[\'},\39\|c:1,\39\.{\']\'})$;\6
\&{gubed}\6
$\\{del\_m}\K\\{gf\_byte}$;\5
$\\{max\_m}\K\\{gf\_byte}$;\5
$\\{del\_n}\K\\{gf\_byte}$;\5
$\\{max\_n}\K\\{gf\_byte}$;\6
\&{if} $\\{del\_m}\L0$ \1\&{then}\5
$\\{empty\_glyph}\K\\{true}$\6
\4\&{else} $\\{empty\_glyph}\K\\{false}$;\2\6
$\\{stow\_signed\_pair}(\\{del\_m}+1)$;\5
$\\{stow\_signed\_pair}(\\{del\_m}-\\{max\_m})$;\5
$\\{stow\_signed\_pair}(\\{del\_n}+1)$;\5
$\\{stow\_signed\_pair}(\\{max\_n})$;\6
\&{debug} \37$\\{print\_ln}(\.{\'\ c=\'},\39\|c:1,\39\.{\'\ del\_m+1=\'},\39%
\\{del\_m}+1:1,\39\.{\'\ del\_m-max\_m=\'},\39\\{del\_m}-\\{max\_m}:1,\39\.{\'\
del\_n+1=\'},\39\\{del\_n}+1:1,\39\.{\'\ max\_n=\'},\39\\{max\_n}:1)$;\6
\&{gubed}\par
\U section~69.\fi
\M74. Having decyphered a \\{boc} command or a \\{boc1} command and having
stored
the necessary information that precedes the mask information in a \\{bgly}
command, we can limit the variety of commands that are to be stored to
only those commands actually needed to specify the mask portion of a
\\{bgly} command.
\fi
\M75. \P$\X75:Pass \\{no\_op}, \\{xxx} and \\{yyy} commands\X\S$\6
\1\&{repeat} \37$\|o\K\\{gf\_byte}$;\6
\&{if} $(\|o=\\{yyy})$ \1\&{then}\6
\&{begin} \37$\|p\K\\{first\_gf\_par}(\|o)$;\5
$\|o\K\\{no\_op}$;\6
\&{end}\6
\4\&{else} \&{if} $(\|o\G\\{xxx1})\W(\|o\L\\{xxx1}+3)$ \1\&{then}\6
\&{begin} \37$\|p\K\\{first\_gf\_par}(\|o)$;\6
\&{while} $\|p>0$ \1\&{do}\6
\&{begin} \37$\|q\K\\{gf\_byte}$;\5
$\\{decr}(\|p)$;\6
\&{end};\2\6
$\|o\K\\{no\_op}$;\6
\&{end};\2\2\6
\4\&{until}\5
$\|o\I\\{no\_op}$;\2\par
\U sections~69 and~106.\fi
\M76. \P$\X76:Stow the glyph details\X\S$\6
$\\{max\_column\_count}\K0$;\C{set for the glyph}\6
$\\{column\_count}\K0$;\5
$\\{row\_count}\K0$;\6
\&{while} $\\{true}$ \1\&{do}\6
\&{begin} \37\\{restart}: \37$\|o\K\\{gf\_byte}$;\6
\&{case} $\|o$ \1\&{of}\6
\4$\\{sixty\_four\_cases}(\\{paint\_0})$: \37\&{begin} \37$\\{column\_count}\K%
\\{column\_count}+\|o-\\{paint\_0}$;\C{$\\{print\_ln}(\.{\'\ s0\ \'},\|o:1)$;}\6
\&{end};\6
\4\\{paint1}: \37\&{begin} \37$\\{stow}(\|o)$;\5
$\|o\K\\{gf\_byte}$;\5
$\\{column\_count}\K\\{column\_count}+\|o$;\C{$\\{print\_ln}(\.{\'\ s1\ \'},%
\|o:1)$;}\6
\&{end};\6
\4\\{paint2}: \37\&{begin} \37$\\{stow}(\|o)$;\5
$\|o\K\\{gf\_byte}$;\5
$\\{stow}(\|o)$;\5
$\\{column\_count}\K\\{column\_count}+256\ast\|o$;\5
$\|o\K\\{gf\_byte}$;\5
$\\{column\_count}\K\\{column\_count}+\|o$;\6
\&{end};\6
\4\\{skip0}: \37\&{begin} \37$\\{incr}(\\{row\_count})$;\6
\&{if} $\\{column\_count}>\\{max\_column\_count}$ \1\&{then}\5
$\\{max\_column\_count}\K\\{column\_count}$;\2\6
$\\{column\_count}\K0$;\6
\&{end};\6
\4\\{skip1}: \37\&{begin} \37$\\{stow}(\|o)$;\5
$\|o\K\\{gf\_byte}$;\5
$\\{row\_count}\K\\{row\_count}+1+\|o$;\6
\&{if} $\\{column\_count}>\\{max\_column\_count}$ \1\&{then}\5
$\\{max\_column\_count}\K\\{column\_count}$;\2\6
$\\{column\_count}\K0$;\6
\&{end};\6
\4$\\{one\_sixty\_five\_cases}(\\{new\_row\_0})$: \37\&{begin} \37$\\{incr}(%
\\{row\_count})$;\6
\&{if} $\\{column\_count}>\\{max\_column\_count}$ \1\&{then}\5
$\\{max\_column\_count}\K\\{column\_count}$;\2\6
$\\{column\_count}\K\|o-\\{new\_row\_0}$;\6
\&{end};\6
\4\\{xxx1}: \37\&{begin} \37$\|o\K\\{gf\_byte}$;\6
\&{while} $\|o>0$ \1\&{do}\6
\&{begin} \37$\|q\K\\{gf\_byte}$;\5
$\\{decr}(\|o)$;\6
\&{end};\2\6
\&{goto} \37\\{restart};\6
\&{end};\6
\4\\{yyy}: \37\&{begin} \37$\|o\K5$;\6
\&{while} $\|o>0$ \1\&{do}\6
\&{begin} \37$\|q\K\\{gf\_byte}$;\5
$\\{decr}(\|o)$;\6
\&{end};\2\6
\&{goto} \37\\{restart};\6
\&{end};\6
\4\\{no\_op}: \37\&{goto} \37\\{restart};\6
\4\\{eoc}: \37\&{goto} \37\\{done};\6
\4\&{othercases} \37$\\{print\_ln}(\.{\'!\ Unexpected\ command:\ \'},\39\|o:1)$%
\2\6
\&{endcases};\5
$\\{stow}(\|o)$;\6
\&{end};\2\6
\4\\{done}: \37$\\{stow}(\|o)$;\C{this should be an \\{eoc} command}\6
\C{$\\{print\_ln}(\.{\'S\ EOC\'})$;}\6
\&{if} $\\{column\_count}>0$ \1\&{then}\5
$\\{incr}(\\{row\_count})$;\C{last row isn't terminated}\2\6
\&{if} $\\{column\_count}>\\{max\_column\_count}$ \1\&{then}\5
$\\{max\_column\_count}\K\\{column\_count}$;\2\6
$\\{mm\_store}[\\{m1\_save},\39\\{m2\_save}]\K\\{max\_column\_count}\mathbin{%
\&{div}}256$;\6
\&{if} $\\{m2\_save}<\\{m2\_max}$ \1\&{then}\5
$\\{incr}(\\{m2\_save})$\6
\4\&{else} \&{begin} \37$\\{m2\_save}\K4$;\6
\&{if} $\\{m1\_save}<\\{m1\_max}$ \1\&{then}\5
$\\{incr}(\\{m1\_save})$\6
\4\&{else} $\\{m1\_save}\K0$;\2\6
\&{end};\2\6
$\\{mm\_store}[\\{m1\_save},\39\\{m2\_save}]\K\\{max\_column\_count}\mathbin{%
\&{mod}}256$;\6
\&{if} $\\{m2\_save}+3<\\{m2\_max}$ \1\&{then}\5
$\\{m2\_save}\K\\{m2\_save}+3$\6
\4\&{else} \&{begin} \37$\\{m2\_save}\K\\{m2\_save}+7-\\{m2\_max}$;\6
\&{if} $\\{m1\_save}<\\{m1\_max}$ \1\&{then}\5
$\\{incr}(\\{m1\_save})$\6
\4\&{else} $\\{m1\_save}\K0$;\2\6
\&{end};\2\6
$\\{mm\_store}[\\{m1\_save},\39\\{m2\_save}]\K\\{row\_count}\mathbin{%
\&{div}}256$;\6
\&{if} $\\{m2\_save}<\\{m2\_max}$ \1\&{then}\5
$\\{incr}(\\{m2\_save})$\6
\4\&{else} \&{begin} \37$\\{m2\_save}\K4$;\6
\&{if} $\\{m1\_save}<\\{m1\_max}$ \1\&{then}\5
$\\{incr}(\\{m1\_save})$\6
\4\&{else} $\\{m1\_save}\K0$;\2\6
\&{end};\2\6
$\\{mm\_store}[\\{m1\_save},\39\\{m2\_save}]\K\\{row\_count}\mathbin{%
\&{mod}}256$;\par
\U sections~69 and~106.\fi
\N77. Optional modes of output.
As normally compiled, the \\{dialog} routine is not called and \.{DVIIMP}
operated in the \\{errors\_only} mode. One can remove the brackets ( {$\to.$} )
that surround the \\{dialog} call in the main program module and
\.{DVIIMP} will then print different quantities of information based on some
options that the user must specify: The \\{out\_mode} level is set to one of
four values (\\{errors\_only}, \\{terse}, \\{verbose}, \\{the\_works}), giving
different degrees of output; and the typeout can be confined to a
restricted subset of the pages by specifying the desired starting page and
the maximum number of pages. Furthermore there is an option to specify the
resolution of an assumed discrete output device, so that pixel-oriented
calculations will be shown; and there is an option to override the
magnification factor that is stated in the \.{DVI} file.
The starting page is specified by giving a sequence of 1 to 10 numbers or
asterisks separated by dots. For example, the specification `\.{1.*.-5}'
can be used to refer to a page output by \TeX\ when $\.{\\count0}=1$
and $\.{\\count2}=-5$. (Recall that \\{bop} commands in a \.{DVI} file
are followed by ten `count' values.) An asterisk matches any number,
so the `\.*' in `\.{1.*.-5}' means that \.{\\count1} is ignored when
specifying the first page. If several pages match the given specification,
\.{DVIIMP} will begin with the earliest such page in the file. The
default specification `\.*' (which matches all pages) therefore denotes
the page at the beginning of the file.
When the modified \.{DVIIMP} begins, it engages the user in a brief dialog
so that the options will be specified. This part of \.{DVIIMP} requires
nonstandard \PASCAL\ constructions to handle the online interaction; so it
may not be easy to allow for this dialog,
and if so, one should simply to stick to the
default options (starting page `\.*' (but printed in
reverse order),
$\\{max\_pages}=1000$, $\\{resolution}=300.0$, $\\{new\_mag}=0$). On other
hand, the
system-dependent routines that are needed are not complicated, so it should
not be terribly difficult to introduce them.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{max\_pages}: \37\\{integer};\C{at most this many $\\{bop}\to\\{eop}$ pages
will be printed}\6
\4\\{resolution}: \37\\{real};\C{pixels per inch}\6
\4\\{new\_mag}: \37\\{integer};\C{if positive, overrides the postamble's
magnification}\par
\fi
\M78. The starting page specification is recorded in two global arrays called
\\{start\_count} and \\{start\_there}. For example, `\.{1.*.-5}' is represented
by $\\{start\_there}[0]=\\{true}$, $\\{start\_count}[0]=1$, $\\{start%
\_there}[1]=\\{false}$,
$\\{start\_there}[2]=\\{true}$, $\\{start\_count}[2]=-5$.
We also set $\\{start\_vals}=2$, to indicate that count 2 was the last one
mentioned. The other values of \\{start\_count} and \\{start\_there} are not
important, in this example.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{start\_count}: \37\&{array} $[0\to9]$ \1\&{of}\5
\\{integer};\C{count values to select starting page}\2\6
\4\\{start\_there}: \37\&{array} $[0\to9]$ \1\&{of}\5
\\{boolean};\C{is the \\{start\_count} value relevant?}\2\6
\4\\{start\_vals}: \37$0\to9$;\C{the last count considered significant}\6
\4\\{count}: \37\&{array} $[0\to9]$ \1\&{of}\5
\\{integer};\C{the count values on the current page}\2\par
\fi
\M79. \P$\X11:Set initial values\X\mathrel{+}\S$\6
$\\{max\_pages}\K1000$;\5
$\\{start\_vals}\K0$;\5
$\\{start\_there}[0]\K\\{false}$;\5
$\\{resolution}\K300.0$;\5
$\\{new\_mag}\K0$;\par
\fi
\M80. Here is a simple subroutine that tests if the current page might be the
starting page.
\Y\P\4\&{function}\1\ \37\\{start\_match}: \37\\{boolean};\C{does \\{count}
match the starting spec?}\6
\4\&{var} \37\|k: \37$0\to9$;\C{loop index}\6
\\{match}: \37\\{boolean};\C{does everything match so far?}\2\6
\&{begin} \37$\\{match}\K\\{true}$;\6
\&{for} $\|k\K0\mathrel{\&{to}}\\{start\_vals}$ \1\&{do}\6
\&{if} $\\{start\_there}[\|k]\W(\\{start\_count}[\|k]\I\\{count}[\|k])$ \1%
\&{then}\5
$\\{match}\K\\{false}$;\2\2\6
$\\{start\_match}\K\\{match}$;\6
\&{end};\par
\fi
\M81\*. The \\{input\_ln} routine waits for the user to type a line at his or
her
terminal; then it puts ASCII-code equivalents for the characters on that line
into the \\{buffer} array. The \\{term\_in} file is used for terminal input,
and \\{term\_out} for terminal output.
\Y\P\D \37$\\{term\_in}\S\\{tty}$\par
\P\D \37$\\{term\_out}\S\\{tty}$\par
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{buffer}: \37\&{array} $[0\to\\{terminal\_line\_length}]$ \1\&{of}\5
\\{ASCII\_code};\2\par
\fi
\M82. Since the terminal is being used for both input and output, some systems
need a special routine to make sure that the user can see a prompt message
before waiting for input based on that message. (Otherwise the message
may just be sitting in a hidden buffer somewhere, and the user will have
no idea what the program is waiting for.) We shall invoke a system-dependent
subroutine \\{update\_terminal} in order to avoid this problem.
\Y\P\D \37$\\{update\_terminal}\S\\{break}(\\{term\_out})$\C{empty the terminal
output buffer}\par
\fi
\M83. During the dialog, \.{DVIIMP} will treat the first blank space in a
line as the end of that line. Therefore \\{input\_ln} makes sure that there
is always at least one blank space in \\{buffer}.
\Y\P\4\&{procedure}\1\ \37\\{input\_ln};\C{inputs a line from the terminal}\6
\4\&{var} \37\|k: \37$0\to\\{terminal\_line\_length}$;\2\6
\&{begin} \37\\{update\_terminal};\5
$\\{reset}(\\{term\_in})$;\6
\&{if} $\\{eoln}(\\{term\_in})$ \1\&{then}\5
$\\{read\_ln}(\\{term\_in})$;\2\6
$\|k\K0$;\6
\&{while} $(\|k<\\{terminal\_line\_length})\W\R\\{eoln}(\\{term\_in})$ \1\&{do}%
\6
\&{begin} \37$\\{buffer}[\|k]\K\\{xord}[\\{term\_in}\↑]$;\5
$\\{incr}(\|k)$;\5
$\\{get}(\\{term\_in})$;\6
\&{end};\2\6
$\\{buffer}[\|k]\K\.{"\ "}$;\6
\&{end};\par
\fi
\M84. The global variable \\{buf\_ptr} is used while scanning each line of
input;
it points to the first unread character in \\{buffer}.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{buf\_ptr}: \37$0\to\\{terminal\_line\_length}$;\C{the number of characters
read}\par
\fi
\M85. Here is a routine that scans a (possibly signed) integer and computes
the decimal value. If no decimal integer starts at \\{buf\_ptr}, the
value 0 is returned. The integer should be less than $2↑{31}$ in
absolute value.
\Y\P\4\&{function}\1\ \37\\{get\_integer}: \37\\{integer};\6
\4\&{var} \37\|x: \37\\{integer};\C{accumulates the value}\6
\\{negative}: \37\\{boolean};\C{should the value be negated?}\2\6
\&{begin} \37\&{if} $\\{buffer}[\\{buf\_ptr}]=\.{"-"}$ \1\&{then}\6
\&{begin} \37$\\{negative}\K\\{true}$;\5
$\\{incr}(\\{buf\_ptr})$;\6
\&{end}\6
\4\&{else} $\\{negative}\K\\{false}$;\2\6
$\|x\K0$;\6
\&{while} $(\\{buffer}[\\{buf\_ptr}]\G\.{"0"})\W(\\{buffer}[\\{buf\_ptr}]\L%
\.{"9"})$ \1\&{do}\6
\&{begin} \37$\|x\K10\ast\|x+\\{buffer}[\\{buf\_ptr}]-\.{"0"}$;\5
$\\{incr}(\\{buf\_ptr})$;\6
\&{end};\2\6
\&{if} $\\{negative}$ \1\&{then}\5
$\\{get\_integer}\K-\|x$\ \&{else} $\\{get\_integer}\K\|x$;\2\6
\&{end};\par
\fi
\M86. The selected options are put into global variables by the \\{dialog}
procedure, which is called just as \.{DVIIMP} begins.
\Y\P\4\&{procedure}\1\ \37\\{dialog};\6
\4\&{label} \37$2,\393,\394,\395$;\6
\4\&{var} \37\|k: \37\\{integer};\C{loop variable}\2\6
\&{begin} \37$\\{rewrite}(\\{term\_out})$;\C{prepare the terminal for output}\6
$\\{write\_ln}(\\{term\_out},\39\\{banner})$;\5
\X87:Determine the desired \\{start\_count} values\X;\6
\X88:Determine the desired \\{max\_pages}\X;\6
\X89:Determine the desired \\{resolution}\X;\6
\X90:Determine the desired \\{new\_mag}\X;\6
\X91:Print all the selected options\X;\6
\&{end};\par
\fi
\M87. \P$\X87:Determine the desired \\{start\_count} values\X\S$\6
\42: \37$\\{write}(\\{term\_out},\39\.{\'Starting\ page\ (default=*):\ \'})$;\5
$\\{start\_vals}\K0$;\5
$\\{start\_there}[0]\K\\{false}$;\5
\\{input\_ln};\5
$\\{buf\_ptr}\K0$;\5
$\|k\K0$;\6
\&{if} $\\{buffer}[0]\I\.{"\ "}$ \1\&{then}\6
\1\&{repeat} \37\&{if} $\\{buffer}[\\{buf\_ptr}]=\.{"*"}$ \1\&{then}\6
\&{begin} \37$\\{start\_there}[\|k]\K\\{false}$;\5
$\\{incr}(\\{buf\_ptr})$;\6
\&{end}\6
\4\&{else} \&{begin} \37$\\{start\_there}[\|k]\K\\{true}$;\5
$\\{start\_count}[\|k]\K\\{get\_integer}$;\6
\&{end};\2\6
\&{if} $(\|k<9)\W(\\{buffer}[\\{buf\_ptr}]=\.{"."})$ \1\&{then}\6
\&{begin} \37$\\{incr}(\|k)$;\5
$\\{incr}(\\{buf\_ptr})$;\6
\&{end}\6
\4\&{else} \&{if} $\\{buffer}[\\{buf\_ptr}]=\.{"\ "}$ \1\&{then}\5
$\\{start\_vals}\K\|k$\6
\4\&{else} \&{begin} \37$\\{write}(\\{term\_out},\39\.{\'Type,\ e.g.,\ 1.*.-5\
to\ specify\ the\ \'})$;\5
$\\{write\_ln}(\\{term\_out},\39\.{\'first\ page\ with\ \\count0=1,\ %
\\count2=-5.\'})$;\5
\&{goto} \372;\6
\&{end};\2\2\6
\4\&{until}\5
$\\{start\_vals}=\|k$\2\2\par
\U section~86.\fi
\M88. \P$\X88:Determine the desired \\{max\_pages}\X\S$\6
\43: \37$\\{write}(\\{term\_out},\39\.{\'Maximum\ number\ of\ pages\
(default=1000000):\ \'})$;\5
$\\{max\_pages}\K1000000$;\5
\\{input\_ln};\5
$\\{buf\_ptr}\K0$;\6
\&{if} $\\{buffer}[0]\I\.{"\ "}$ \1\&{then}\6
\&{begin} \37$\\{max\_pages}\K\\{get\_integer}$;\6
\&{if} $\\{max\_pages}\L0$ \1\&{then}\6
\&{begin} \37$\\{write\_ln}(\\{term\_out},\39\.{\'Please\ type\ a\ positive\
number.\'})$;\5
\&{goto} \373;\6
\&{end};\2\6
\&{end}\2\par
\U section~86.\fi
\M89. \P$\X89:Determine the desired \\{resolution}\X\S$\6
\44: \37$\\{write}(\\{term\_out},\39\.{\'Assumed\ device\ resolution\'})$;\5
$\\{write}(\\{term\_out},\39\.{\'\ in\ pixels\ per\ inch\ (default=300/1):\ %
\'})$;\5
$\\{resolution}\K300.0$;\5
\\{input\_ln};\5
$\\{buf\_ptr}\K0$;\6
\&{if} $\\{buffer}[0]\I\.{"\ "}$ \1\&{then}\6
\&{begin} \37$\|k\K\\{get\_integer}$;\6
\&{if} $(\|k>0)\W(\\{buffer}[\\{buf\_ptr}]=\.{"/"})\W(\\{buffer}[\\{buf%
\_ptr}+1]>\.{"0"})\W(\\{buffer}[\\{buf\_ptr}+1]\L\.{"9"})$ \1\&{then}\6
\&{begin} \37$\\{incr}(\\{buf\_ptr})$;\5
$\\{resolution}\K\|k/\\{get\_integer}$;\6
\&{end}\6
\4\&{else} \&{begin} \37$\\{write}(\\{term\_out},\39\.{\'Type\ a\ ratio\ of\
positive\ integers;\'})$;\5
$\\{write\_ln}(\\{term\_out},\39\.{\'\ (1\ pixel\ per\ mm\ would\ be\ 254/10).%
\'})$;\5
\&{goto} \374;\6
\&{end};\2\6
\&{end}\2\par
\U section~86.\fi
\M90. \P$\X90:Determine the desired \\{new\_mag}\X\S$\6
\45: \37$\\{write}(\\{term\_out},\39\.{\'New\ magnification\ (default=0\ to\
keep\ the\ old\ one):\ \'})$;\5
$\\{new\_mag}\K0$;\5
\\{input\_ln};\5
$\\{buf\_ptr}\K0$;\6
\&{if} $\\{buffer}[0]\I\.{"\ "}$ \1\&{then}\6
\&{if} $(\\{buffer}[0]\G\.{"0"})\W(\\{buffer}[0]\L\.{"9"})$ \1\&{then}\5
$\\{new\_mag}\K\\{get\_integer}$\6
\4\&{else} \&{begin} \37$\\{write}(\\{term\_out},\39\.{\'Type\ a\ positive\
integer\ to\ override\ \'})$;\5
$\\{write\_ln}(\\{term\_out},\39\.{\'the\ magnification\ in\ the\ DVI\ file.%
\'})$;\5
\&{goto} \375;\6
\&{end}\2\2\par
\U section~86.\fi
\M91. After the dialog is over, we print the options so that the user
can see what \.{DVIIMP} thought was specified.
\Y\P$\4\X91:Print all the selected options\X\S$\6
$\\{print\_ln}(\.{\'Options\ selected:\'})$;\5
$\\{print}(\.{\'\ \ Starting\ page\ =\ \'})$;\6
\&{for} $\|k\K0\mathrel{\&{to}}\\{start\_vals}$ \1\&{do}\6
\&{begin} \37\&{if} $\\{start\_there}[\|k]$ \1\&{then}\5
$\\{print}(\\{start\_count}[\|k]:1)$\6
\4\&{else} $\\{print}(\.{\'*\'})$;\2\6
\&{if} $\|k<\\{start\_vals}$ \1\&{then}\5
$\\{print}(\.{\'.\'})$\6
\4\&{else} $\\{print\_ln}(\.{\'\ \'})$;\2\6
\&{end};\2\6
$\\{print\_ln}(\.{\'\ \ Maximum\ number\ of\ pages\ =\ \'},\39\\{max%
\_pages}:1)$;\5
$\\{print\_ln}(\.{\'\ \ Resolution\ =\ \'},\39\\{resolution}:12:8,\39\.{\'\
pixels\ per\ inch\'})$;\6
\&{if} $\\{new\_mag}>0$ \1\&{then}\5
$\\{print\_ln}(\.{\'\ \ New\ magnification\ factor\ =\ \'},\39\\{new%
\_mag}/1000:8:3)$\2\par
\U section~86.\fi
\N92. Identifying and loading fonts.
\.{DVIIMP} stores the raster information relating to the glyphs that it
uses in a large \\{mm\_store} array and stores the location of these rasters
and information relating to their state in a \\{glyph\_ptr} array. Additional
\\{width} and \\{pixel\_width} information is stored in still other arrays.
It is usually not possible to provide a large enough \\{mm\_store} space
for all of the fonts that may be used in some documents. \.{DVIIMP}
provides the facility for removing fonts from \\{mm\_store} to make space for
additional fonts and then for restoring the removed fonts if this becomes
necessary.
The general procedure is to
read the \.{DVI} postamble first to get the desired \\{fnt\_def1}
information and to store this identifying information initially without
storing the font rasters. An array $\\{font\_state}[\|f]$ is used to keep a
record of the state of all fonts with the values set to 0 when the font
identifying information is read. Later, when a \\{fnt\_num} command is
encountered in the body of the \.{DVI} file, the rasters for the entire
font are read in and the \\{font\_state} value for this font is changed to 1.
However, glyphs are only downloaded as they are needed for the first time.
The location and state for each individual glyph in all the fonts used is
kept in the \\{glyph\_ptr} array. This array is initially set to -1,
indicating that the referenced glyphs either do not exist or that they
have not yet been read into the \\{mm\_store} memory. The individual glyph
pointers are then set to positive values (actually, greater than 3) when
the font rasters are read in, recording the position in the \\{mm\_store}
where the glyph is stored. These numbers are negated when each individual
glyph is downloaded. Finally, if it becomes necessary to remove rasters
to make space for other fonts, the positive \\{glyph\_ptr} values for all
glyphs of the removed fonts are set to zero without touching the negative
pointer values (which still indicate the downloaded or non-existant states
of the glyphs in question).
Removing the rasters for the downloaded glyphs does not in any way prevent the
continued use of these particular glyphs and no effort is made to reload any
particular font until a request is encountered for a removed non-down-loaded
glyph, as signalled by encountering a 0 value in the \\{glyph\_ptr} array. At
this time, only the non-down-loaded glyphs of the reloaded font are restored,
with a possible substantial reduction in the space requirements as compared
with the font's initial needs, since most of the more commonly used
glyphs may have already been downloaded.
A number of different utility procedures and functions will be needed.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{font\_state}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{0 unloaded, 1 loaded}\2\6
\4\\{font\_a\_val}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{length of directory name}\2\6
\4\\{font\_l\_val}: \37\&{array} $[0\to\\{max\_fonts}]$ \1\&{of}\5
\\{integer};\C{length of font name}\2\6
\4\\{scale\_val}: \37\&{array} $[1\to12]$ \1\&{of}\5
\\{integer};\C{table of preferred font scale values}\2\par
\fi
\M93. \P$\X11:Set initial values\X\mathrel{+}\S$\6
$\\{jj}\K1.0$;\6
\&{for} $\|i\K1\mathrel{\&{to}}7$ \1\&{do}\6
\&{begin} \37$\\{jj}\K1.2\ast\\{jj}$;\5
$\\{scale\_val}[\|i]\K\\{round}(\\{jj}\ast\\{resolution})$;\6
\&{debug} \37$\\{print\_ln}(\.{\'\ \ i=\'},\39\|i:1,\39\.{\'\ jj=\'},\39%
\\{jj}:1,\39\.{\'\ scale\ val=\'},\39\\{scale\_val}[\|i]:1)$;\6
\&{gubed}\6
\&{end};\2\6
$\\{scale\_val}[8]\K4\ast\\{round}(\\{resolution})$;\C{magnifications of 4000
and 5000 are sometines used}\6
$\\{scale\_val}[9]\K5\ast\\{round}(\\{resolution})$;\5
$\\{scale\_val}[10]\K6\ast\\{round}(\\{resolution})$;\5
$\\{scale\_val}[11]\K7\ast\\{round}(\\{resolution})$;\5
$\\{scale\_val}[12]\K8\ast\\{round}(\\{resolution})$;\par
\fi
\M94. A minor problem in specifying the sizes of scaled fonts arises because
of the fact that \.{\\magstep} definitions are in terms of the rounded
values based on the magnification times 1000. For example, one will get
different values for 1)~a magnification of 1200 as applied to a font
scaled \.{\\magstep4}, and for 2)~a magnification of 1000 as applied to a
font scaled \.{\\magstep5}. The following table and function provides the
mechanism for resolving these differences by identifying the nearest match
in terms of the overall actual magnification times the resolution. At
\.{SAIL}, this figure is used as the file-name extension for standard
\.{GF} files.
\Y\P\4\&{function}\1\ \37$\\{reconcile\_scale}(\|m:\\{integer})$: \37%
\\{integer};\6
\4\&{label} \37\\{done};\6
\4\&{var} \37\|i: \37$1\to12$;\2\6
\&{begin} \37$\\{reconcile\_scale}\K\|m$;\6
\&{for} $\|i\K1\mathrel{\&{to}}12$ \1\&{do}\6
\&{if} $\\{abs}(\|m-\\{scale\_val}[\|i])<\\{abs}(\|m-\\{scale\_val}[\|i+1])$ \1%
\&{then}\6
\&{begin} \37\&{if} $\\{abs}(\|m-\\{scale\_val}[\|i])<4$ \1\&{then}\5
$\\{reconcile\_scale}\K\\{scale\_val}[\|i]$;\2\6
\&{goto} \37\\{done};\6
\&{end};\2\2\6
\4\\{done}: \37\&{end};\par
\fi
\M95. The following subroutine does the necessary things when a \\{fnt\_def}
command is being processed in the postamble.
\Y\P\4\&{procedure}\1\ \37$\\{identify\_font}(\|e:\\{integer})$;\C{\|e is an
external font number}\6
\4\&{var} \37\|f: \37$0\to\\{max\_fonts}$;\5
\|p: \37\\{integer};\C{length of the area/directory spec}\6
\|n: \37\\{integer};\C{length of the font name proper}\6
$\|c,\39\|q,\39\|d$: \37\\{integer};\C{check sum, scaled size, and design size}%
\6
\|r: \37$0\to\\{name\_length}$;\C{index into \\{cur\_name}}\6
$\|j,\39\|k$: \37$0\to\\{name\_size}$;\C{indices into \\{names}}\6
\|m: \37\\{integer};\C{available for use in \\{mag} effect caculations}\6
\\{mismatch}: \37\\{boolean};\C{do names disagree?}\2\6
\&{begin} \37\&{if} $\\{nf}=\\{max\_fonts}$ \1\&{then}\5
$\\{abort}(\.{\'DVIIMP\ capacity\ exceeded\ (max\ fonts=\'},\39\\{max%
\_fonts}:1,\39\.{\')!\'})$;\2\6
$\\{font\_num}[\\{nf}]\K\|e$;\5
$\|f\K0$;\6
\&{while} $\\{font\_num}[\|f]\I\|e$ \1\&{do}\5
$\\{incr}(\|f)$;\2\6
\X96:Read the font parameters into position for font \\{nf}\X;\6
\X97:Verify \\{font\_scaled\_size} and \\{font\_design\_size} for size\X;\6
$\\{font\_state}[\\{nf}]\K0$;\C{font identified but not read in}\6
$\\{font\_space}[\\{nf}]\K\|q\mathbin{\&{div}}6$;\C{this is a 3-unit ``thin
space''}\6
$\\{incr}(\\{nf})$;\C{signalling completion of identification}\6
$\\{font\_space}[\\{nf}]\K0$;\C{for \\{out\_space} and \\{out\_vmove}}\6
\&{end};\par
\fi
\M96. \P$\X96:Read the font parameters into position for font \\{nf}\X\S$\6
$\|c\K\\{signed\_quad}$;\5
$\\{font\_check\_sum}[\\{nf}]\K\|c$;\6
$\|q\K\\{signed\_quad}$;\5
$\\{font\_scaled\_size}[\\{nf}]\K\|q$;\6
$\|d\K\\{signed\_quad}$;\5
$\\{font\_design\_size}[\\{nf}]\K\|d$;\6
$\|p\K\\{get\_byte}$;\5
$\\{font\_a\_val}[\\{nf}]\K\|p$;\6
$\|n\K\\{get\_byte}$;\5
$\\{font\_l\_val}[\\{nf}]\K\|n$;\6
\&{if} $\\{font\_name}[\\{nf}]+\|n+\|p>\\{name\_size}$ \1\&{then}\5
$\\{abort}(\.{\'DVIIMP\ capacity\ exceeded\ (name\ size=\'},\39\\{name%
\_size}:1,\39\.{\')!\'})$;\2\6
$\\{font\_name}[\\{nf}+1]\K\\{font\_name}[\\{nf}]+\|n+\|p$;\6
\&{if} $\|n+\|p=0$ \1\&{then}\5
$\\{abort}(\.{\'\ null\ n+p\ \'})$\6
\4\&{else} \&{for} $\|k\K\\{font\_name}[\\{nf}]\mathrel{\&{to}}\\{font\_name}[%
\\{nf}+1]-1$ \1\&{do}\5
$\\{names}[\|k]\K\\{get\_byte}$;\2\2\6
$\|m\K\\{round}((0.3\ast\\{mag}\ast\|q)/\|d)$;\6
\&{if} $(\|m\G\\{round}(1.2\ast\\{resolution}))\W(\|m<1500)$ \1\&{then}\5
$\|m\K\\{reconcile\_scale}(\|m)$;\2\6
$\\{font\_m\_val}[\\{nf}]\K\|m$;\6
\&{debug} \37$\\{incr}(\\{nf})$;\5
$\\{print\_font}(\\{nf}-1)$;\5
$\\{print}(\.{\'.\'},\39\|m:1,\39\.{\'\ \'})$;\5
$\\{print\_ln}(\.{\'\ e=\'},\39\|e:1,\39\.{\'\ f=\'},\39\\{nf}:1,\39\.{\'\ c=%
\'},\39\|c:1,\39\.{\'\ q=\'},\39\|q:1,\39\.{\'\ d=\'},\39\|d:1,\39\.{\'\ p=\'},%
\39\|p:1,\39\.{\'\ n=\'},\39\|n:1)$;\5
$\\{decr}(\\{nf})$;\6
\&{gubed}\par
\U section~95.\fi
\M97. \P$\X97:Verify \\{font\_scaled\_size} and \\{font\_design\_size} for size%
\X\S$\6
\&{if} $(\|q\L0)\V(\|q\G\O{1000000000})$ \1\&{then}\5
$\\{print}(\.{\'---may\ not\ load,\ bad\ scale\ (\'},\39\|q:1,\39\.{\')!\'})$\6
\4\&{else} \&{if} $(\|d\L0)\V(\|d\G\O{1000000000})$ \1\&{then}\5
$\\{print}(\.{\'---may\ not\ load,\ bad\ design\ size\ (\'},\39\|d:1,\39\.{\')!%
\'})$;\2\2\par
\U section~95.\fi
\M98. It will be desirable to skip over the \\{fnt\_def1} commands that are
found in
the body of the \.{DVI} file as our method of reading the pages in reverse
order makes it impractical for us to use them.
\Y\P\4\&{procedure}\1\ \37\\{skip\_it};\C{to bypass the \\{fnt\_def1} commands
in the body}\6
\4\&{var} \37$\|i,\39\|j,\39\|k$: \37\\{integer};\2\6
\&{begin} \37\&{for} $\|i\K1\mathrel{\&{to}}13$ \1\&{do}\5
$\|j\K\\{get\_byte}$;\2\6
$\|j\K\|j+\\{get\_byte}$;\6
\&{if} $\|j>0$ \1\&{then}\6
\&{for} $\|i\K1\mathrel{\&{to}}\|j$ \1\&{do}\5
$\|k\K\\{get\_byte}$;\2\2\6
\&{end};\par
\fi
\M99. We will have occasion to call the following from two different locations.
\Y\P\4\&{procedure}\1\ \37\\{get\_gf\_file};\6
\4\&{var} \37\|p: \37\\{integer};\C{length of the area/directory spec}\6
\|n: \37\\{integer};\C{length of the font name proper}\6
$\|c,\39\|q,\39\|d$: \37\\{integer};\C{check sum, scaled size, and design size}%
\6
\|r: \37$0\to\\{name\_length}$;\C{index into \\{cur\_name}}\6
$\|j,\39\|k$: \37$0\to\\{name\_size}$;\C{indices into \\{names}}\6
\|m: \37\\{integer};\C{available for use in \\{mag} effect caculations}\6
\\{mismatch}: \37\\{boolean};\C{do names disagree?}\2\6
\&{begin} \37$\|m\K\\{font\_m\_val}[\\{cur\_font}]$;\5
$\|p\K\\{font\_a\_val}[\\{cur\_font}]$;\5
$\|n\K\\{font\_l\_val}[\\{cur\_font}]$;\5
\X102\*:Move font name into the \\{cur\_name} string\X;\6
\&{debug} \37$\\{print\_font}(\\{cur\_font})$;\5
$\\{print}(\.{\'.\'},\39\|m:1)$;\5
$\\{print}(\.{\'(\'},\39\\{cur\_font}:1,\39\.{\')\ \'})$;\6
\&{gubed}\6
\\{open\_gf\_file};\6
\&{if} $\\{eof}(\\{gf\_file})$ \1\&{then}\6
\&{begin} \37$\\{print\_ln}(\.{\'\'})$;\5
$\\{print\_font}(\\{cur\_font})$;\5
$\\{print\_extension}(\|m)$;\6
\&{debug} \37$\\{print}(\.{\'(\'},\39\\{cur\_font}:1,\39\.{\')\ \'})$;\6
\&{gubed}\6
$\\{print}(\.{\'\ not\ found\'})$;\5
\X103\*:Move font name into the \\{cur\_tfm\_name} string\X;\6
\\{open\_tfm\_file};\6
\&{if} $\\{eof}(\\{tfm\_file})$ \1\&{then}\6
\&{begin} \37$\\{print}(\.{\'\ and\ there\ is\ no\ |tfm|\ file\ \'})$;\5
$\\{font\_state}[\\{cur\_font}]\K-2$;\6
\&{end}\6
\4\&{else} \&{begin} \37$\\{print}(\.{\',\ characters\ will\ be\ left\ blank.%
\'})$;\5
$\\{font\_state}[\\{cur\_font}]\K2$;\6
\&{end};\2\6
\&{end};\2\6
\&{end};\par
\fi
\M100\*. If $\|p=0$, i.e., if no font directory has been specified, \.{DVIIMP}
is supposed to use the default font directory, which is a
system-dependent place where the standard fonts are kept.
The string variable \\{default\_directory} contains the name of this area.
\Y\P\D \37$\\{default\_directory\_name}\S\.{\'[GF,SYS]\'}$\C{change this to the
correct name}\par
\P\D \37$\\{default\_directory\_name\_length}=8$\C{change this to the correct
length}\par
\P\D \37$\\{dflt\_tfm\_directory\_name}\S\.{\'[TEX,SYS]\'}$\C{change this to
the correct name}\par
\P\D \37$\\{dflt\_tfm\_directory\_name\_length}=9$\C{change this to the correct
length}\par
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{default\_directory}: \37\&{packed} \37\&{array} $[1\to\\{default%
\_directory\_name\_length}]$ \1\&{of}\5
\\{char};\2\6
\4\\{dflt\_tfm\_directory}: \37\&{packed} \37\&{array} $[1\to\\{dflt\_tfm%
\_directory\_name\_length}]$ \1\&{of}\5
\\{char};\2\par
\fi
\M101. \P$\X11:Set initial values\X\mathrel{+}\S$\6
$\\{default\_directory}\K\\{default\_directory\_name}$;\5
$\\{dflt\_tfm\_directory}\K\\{dflt\_tfm\_directory\_name}$;\par
\fi
\M102\*. The string \\{cur\_name} is supposed to be set to the external name of
the
\.{GF} file for the current font. This usually means that we need to
prepend the name of the default directory, and
to append the suffix `\.{.GF}'. But at {\mc SAIL} we append the
directory name after the font name. And we compress `\.{oldenglish}' to
`\.{oldish}'.
\Y\P$\4\X102\*:Move font name into the \\{cur\_name} string\X\S$\6
\&{for} $\|k\K1\mathrel{\&{to}}\\{name\_length}$ \1\&{do}\5
$\\{cur\_name}[\|k]\K\.{\'\ \'}$;\2\6
$\|r\K0$;\6
\&{for} $\|k\K\\{font\_name}[\\{cur\_font}]+\|p\mathrel{\&{to}}\\{font\_name}[%
\\{cur\_font}+1]-1$ \1\&{do}\6
\&{if} $(\|k\L\\{font\_name}[\\{cur\_font}]+\|p+2)\V(\|k\G\\{font\_name}[\\{cur%
\_font}+1]-3)$ \1\&{then}\6
\&{begin} \37$\\{incr}(\|r)$;\6
\&{if} $\|r+4>\\{name\_length}$ \1\&{then}\5
$\\{abort}(\.{\'DVItype\ capacity\ exceeded\ (max\ font\ name\ length=\'},\39%
\\{name\_length}:1,\39\.{\')!\'})$;\2\6
\&{if} $(\\{names}[\|k]\G\.{"a"})\W(\\{names}[\|k]\L\.{"z"})$ \1\&{then}\5
$\\{cur\_name}[\|r]\K\\{xchr}[\\{names}[\|k]-\O{40}]$\6
\4\&{else} $\\{cur\_name}[\|r]\K\\{xchr}[\\{names}[\|k]]$;\2\6
\&{end};\2\2\6
$\|m\K\\{font\_m\_val}[\\{cur\_font}]$;\5
$\\{cur\_name}[\|r+1]\K\.{\'.\'}$;\5
$\\{cur\_name}[\|r+2]\K\\{xchr}[\|m\mathbin{\&{div}}100+\O{60}]$;\5
$\\{cur\_name}[\|r+3]\K\\{xchr}[(\|m\mathbin{\&{mod}}100)\mathbin{\&{div}}10+%
\O{60}]$;\5
$\\{cur\_name}[\|r+4]\K\\{xchr}[\|m\mathbin{\&{mod}}10+\O{60}]$;\5
$\|r\K\|r+4$;\6
\&{if} $\|p=0$ \1\&{then}\6
\&{for} $\|k\K1\mathrel{\&{to}}\\{default\_directory\_name\_length}$ \1\&{do}\6
\&{begin} \37$\\{incr}(\|r)$;\6
\&{if} $\|r>\\{name\_length}$ \1\&{then}\5
$\\{abort}(\.{\'Font\ name\ is\ too\ long!\'})$;\2\6
$\\{cur\_name}[\|r]\K\\{default\_directory}[\|k]$;\6
\&{end}\2\6
\4\&{else} \&{for} $\|k\K\\{font\_name}[\\{cur\_font}]\mathrel{\&{to}}\\{font%
\_name}[\\{cur\_font}]+\|p-1$ \1\&{do}\6
\&{begin} \37$\\{incr}(\|r)$;\6
\&{if} $\|r>\\{name\_length}$ \1\&{then}\5
$\\{abort}(\.{\'Font\ name\ is\ too\ long!\'})$;\2\6
\&{if} $(\\{names}[\|k]\G\.{"a"})\W(\\{names}[\|k]\L\.{"z"})$ \1\&{then}\5
$\\{cur\_name}[\|r]\K\\{xchr}[\\{names}[\|k]-\O{40}]$\6
\4\&{else} $\\{cur\_name}[\|r]\K\\{xchr}[\\{names}[\|k]]$;\2\6
\&{end}\2\2\par
\U section~99.\fi
\M103\*. Normally, we only need to reference the \.{GF} files. On those
occasions when no \.{GF} file is to be found we will want to obtain the
glyph widths from a \.{TFM} file.
The following takes care of {\mc SAIL} conventions.
\Y\P$\4\X103\*:Move font name into the \\{cur\_tfm\_name} string\X\S$\6
\&{for} $\|k\K1\mathrel{\&{to}}\\{name\_length}$ \1\&{do}\5
$\\{cur\_tfm\_name}[\|k]\K\.{\'\ \'}$;\2\6
$\|r\K0$;\6
\&{for} $\|k\K\\{font\_name}[\\{cur\_font}]+\|p\mathrel{\&{to}}\\{font\_name}[%
\\{cur\_font}+1]-1$ \1\&{do}\6
\&{if} $(\|k\L\\{font\_name}[\\{cur\_font}]+\|p+2)\V(\|k\G\\{font\_name}[\\{cur%
\_font}+1]-3)$ \1\&{then}\6
\&{begin} \37$\\{incr}(\|r)$;\6
\&{if} $\|r+4>\\{name\_length}$ \1\&{then}\5
$\\{abort}(\.{\'DVItype\ capacity\ exceeded\ (max\ font\ name\ length=\'},\39%
\\{name\_length}:1,\39\.{\')!\'})$;\2\6
\&{if} $(\\{names}[\|k]\G\.{"a"})\W(\\{names}[\|k]\L\.{"z"})$ \1\&{then}\5
$\\{cur\_tfm\_name}[\|r]\K\\{xchr}[\\{names}[\|k]-\O{40}]$\6
\4\&{else} $\\{cur\_tfm\_name}[\|r]\K\\{xchr}[\\{names}[\|k]]$;\2\6
\&{end};\2\2\6
$\\{cur\_tfm\_name}[\|r+1]\K\.{\'.\'}$;\5
$\\{cur\_tfm\_name}[\|r+2]\K\.{\'T\'}$;\5
$\\{cur\_tfm\_name}[\|r+3]\K\.{\'F\'}$;\5
$\\{cur\_tfm\_name}[\|r+4]\K\.{\'M\'}$;\5
$\|r\K\|r+4$;\6
\&{if} $\|p=0$ \1\&{then}\6
\&{for} $\|k\K1\mathrel{\&{to}}\\{dflt\_tfm\_directory\_name\_length}$ \1\&{do}%
\6
\&{begin} \37$\\{incr}(\|r)$;\6
\&{if} $\|r>\\{name\_length}$ \1\&{then}\5
$\\{abort}(\.{\'Font\ name\ is\ too\ long!\'})$;\2\6
$\\{cur\_tfm\_name}[\|r]\K\\{dflt\_tfm\_directory}[\|k]$;\6
\&{end}\2\6
\4\&{else} \&{for} $\|k\K\\{font\_name}[\\{cur\_font}]\mathrel{\&{to}}\\{font%
\_name}[\\{cur\_font}]+\|p-1$ \1\&{do}\6
\&{begin} \37$\\{incr}(\|r)$;\6
\&{if} $\|r>\\{name\_length}$ \1\&{then}\5
$\\{abort}(\.{\'Font\ name\ is\ too\ long!\'})$;\2\6
\&{if} $(\\{names}[\|k]\G\.{"a"})\W(\\{names}[\|k]\L\.{"z"})$ \1\&{then}\5
$\\{cur\_tfm\_name}[\|r]\K\\{xchr}[\\{names}[\|k]-\O{40}]$\6
\4\&{else} $\\{cur\_tfm\_name}[\|r]\K\\{xchr}[\\{names}[\|k]]$;\2\6
\&{end}\2\2\par
\U section~99.\fi
\M104. We now come to the routines for reloading a font that has been removed.
\Y\P\4\&{procedure}\1\ \37\\{reload\_font};\6
\4\&{label} \37$\\{done},\39\\{restart}$;\6
\4\&{var} \37\|k: \37\\{integer};\C{index for loops}\6
\|c: \37\\{integer};\C{ used it index character number}\6
\|o: \37\\{integer};\C{used to hold \\{gf} commands}\6
\|p: \37\\{integer};\C{used to hold \\{gf} parameter}\6
\|a: \37\\{integer};\C{used to hold \\{gf} parameter}\6
\\{del\_m}: \37\\{integer};\C{used to hold \\{gf} parameter}\6
\\{del\_n}: \37\\{integer};\C{used to hold \\{gf} parameter}\6
$\\{mm\_save},\39\\{m1\_save},\39\\{m2\_save}$: \37\\{integer};\C{to allow
corrections}\2\6
\&{begin} \37\\{get\_gf\_file};\5
\X105:Skip over the preamble\X;\6
\X106:Restow glyph rasters that have not been downloaded\X;\6
$\\{font\_state}[\\{cur\_font}]\K1$;\C{signalling that font is loaded}\6
\&{end};\par
\fi
\M105. \P$\X105:Skip over the preamble\X\S$\6
$\|o\K\\{gf\_byte}$;\C{fetch the first byte}\6
$\|o\K\\{gf\_byte}$;\C{fetch the identification byte}\6
$\|o\K\\{gf\_byte}$;\C{fetch the length of the introductory comment}\6
\&{while} $\|o>0$ \1\&{do}\6
\&{begin} \37$\\{decr}(\|o)$;\5
$\|p\K\\{gf\_byte}$;\6
\&{end};\2\par
\U section~104.\fi
\M106. \P$\X106:Restow glyph rasters that have not been downloaded\X\S$\6
$\|k\K0$;\6
\&{while} $\\{font\_order}[\|k]\G0$ \1\&{do}\5
$\\{incr}(\|k)$;\2\6
$\\{font\_order}[\|k]\K\\{cur\_font}$;\C{add this font to ordered list}\6
\1\&{repeat} \37$\\{gf\_prev\_ptr}\K\\{cur\_gf\_loc}$;\5
\X75:Pass \\{no\_op}, \\{xxx} and \\{yyy} commands\X;\6
\&{if} $(\|o=\\{boc})\V(\|o=\\{boc1})$ \1\&{then}\6
\&{begin} \37\&{if} $\|o=\\{boc}$ \1\&{then}\5
\X107:Read the \\{boc} information\X\6
\4\&{else} \X108:Read the \\{boc1} information\X;\2\6
\&{debug} \37$\\{print}(\.{\'\ c=\'},\39\|c:1)$;\6
\&{gubed}\6
\&{if} $\\{glyph\_ptr}[\\{data\_base}[\\{cur\_font}]+\|c]<0$ \1\&{then}\5
\X110:Pass over the raster details\X\C{glyph has been downloaded}\6
\4\&{else} \&{begin} \37$\\{mm\_save}\K\\{mm}$;\5
$\\{m1\_save}\K\\{m1}$;\5
$\\{m2\_save}\K\\{m2}$;\C{for possible width and height corrections}\6
$\\{glyph\_ptr}[\\{data\_base}[\\{cur\_font}]+\|c]\K\\{m1}\ast\\{m2\_size}+%
\\{m2}$;\C{save glyph starting address}\6
\&{debug} \37$\\{print}(\.{\'\ (\'},\39\\{cur\_font}:1,\39\.{\')\'},\39\|c:1,%
\39\.{\'[\'},\39\\{m1}:1,\39\.{\',\'},\39\\{m2}:1,\39\.{\']\'})$;\6
\&{gubed}\6
\X109:Stow the \\{boc} or \\{boc1} information\X;\6
\X76:Stow the glyph details\X;\6
\&{end};\2\6
\&{end};\2\6
\4\&{until}\5
$\|o=\\{post}$;\2\par
\U section~104.\fi
\M107. \P$\X107:Read the \\{boc} information\X\S$\6
\&{begin} \37$\\{char\_code}\K\\{gf\_signed\_quad}$;\5
$\|p\K\\{gf\_signed\_quad}$;\5
$\|c\K\\{char\_code}\mathbin{\&{mod}}256$;\6
\&{if} $\|c<0$ \1\&{then}\5
$\|c\K\|c+256$;\2\6
\&{debug} \37$\\{print}(\.{\'[\'},\39\|c:1,\39\.{\']\'})$;\6
\&{if} $\\{char\_code}\I\|c$ \1\&{then}\5
$\\{print}(\.{\'\ in\ family\ \'},\39(\\{char\_code}-\|c)\mathbin{%
\&{div}}256:1)$;\2\6
\&{gubed}\6
$\\{min\_m}\K\\{gf\_signed\_quad}$;\5
$\\{max\_m}\K\\{gf\_signed\_quad}$;\5
$\\{min\_n}\K\\{gf\_signed\_quad}$;\5
$\\{max\_n}\K\\{gf\_signed\_quad}$;\5
$\\{del\_m}\K\\{max\_m}-\\{min\_m}$;\5
$\\{del\_n}\K\\{max\_n}-\\{min\_n}$;\6
\&{end}\par
\U section~106.\fi
\M108. \P$\X108:Read the \\{boc1} information\X\S$\6
\&{begin} \37$\\{char\_code}\K\\{gf\_byte}$;\5
$\|p\K-1$;\5
$\|c\K\\{char\_code}$;\5
$\\{del\_m}\K\\{gf\_byte}$;\5
$\\{max\_m}\K\\{gf\_byte}$;\5
$\\{del\_n}\K\\{gf\_byte}$;\5
$\\{max\_n}\K\\{gf\_byte}$;\5
$\\{min\_m}\K\\{max\_m}-\\{del\_m}$;\6
\&{end}\par
\U section~106.\fi
\M109. \P$\X109:Stow the \\{boc} or \\{boc1} information\X\S$\6
$\\{stow\_signed\_pair}(\\{del\_m}+1)$;\5
$\\{stow\_signed\_pair}(-\\{min\_m})$;\C{this is the initial \|m value}\6
$\\{stow\_signed\_pair}(\\{del\_n}+1)$;\5
$\\{stow\_signed\_pair}(\\{max\_n})$;\par
\U section~106.\fi
\M110. \P$\X110:Pass over the raster details\X\S$\6
\C{this glyph has been downloaded}\6
\&{begin} \37$\|o\K\\{gf\_byte}$;\6
\&{while} $\|o\I\\{eoc}$ \1\&{do}\6
\&{begin} \37$\|a\K\\{cur\_gf\_loc}$;\6
\&{while} $(\|o<\\{paint1})\V(\|o=\\{skip0})\V((\|o\G\\{new\_row\_0})\W(\|o\L%
\\{new\_row\_164}))$ \1\&{do}\5
$\|o\K\\{gf\_byte}$;\2\6
\&{if} $(\|o=\\{paint1})\V(\|o=\\{skip1})$ \1\&{then}\6
\&{begin} \37$\|p\K\\{gf\_byte}$;\5
$\|o\K\\{gf\_byte}$;\6
\&{end}\6
\4\&{else} \&{if} $(\|o=\\{paint2})\V(\|o=\\{skip2})$ \1\&{then}\6
\&{begin} \37$\|p\K\\{gf\_byte}$;\5
$\|p\K\\{gf\_byte}$;\5
$\|o\K\\{gf\_byte}$;\6
\&{end}\6
\4\&{else} \&{if} $\|o=\\{xxx1}$ \1\&{then}\6
\&{begin} \37\C{\MF\ will not do this but it is allowed}\6
$\|p\K\\{gf\_byte}$;\6
\&{while} $\|p>0$ \1\&{do}\6
\&{begin} \37$\|q\K\\{gf\_byte}$;\5
$\\{decr}(\|p)$;\6
\&{end};\2\6
$\|o\K\\{gf\_byte}$;\6
\&{end};\2\2\2\6
\&{end};\2\6
\&{end}\par
\U section~106.\fi
\N111. Downloading glyph information.
As mentioned earlier, the information for each used glyph (as stored in
the \\{mm\_store} array) will have to be translated and downloaded by means of
an \\{im\_bgly} command on the first occasion that the glyph is to be
printed. The following definitions and tables will assist in this work:
\Y\P\D \37$\\{advance\_q}\S$\1\6
\&{begin} \37\&{if} $\\{q2}<\\{m2\_max}$ \1\&{then}\5
$\\{incr}(\\{q2})$\6
\4\&{else} \&{begin} \37$\\{q2}\K4$;\C{$-4<\\{m2}<4$ is left free for other
uses}\6
\&{if} $\\{q1}<\\{m1\_max}$ \1\&{then}\5
$\\{incr}(\\{q1})$\6
\4\&{else} $\\{q1}\K0$;\2\6
\&{end};\2\6
\&{end}\2\par
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{atab}: \37\&{array} $[1\to8]$ \1\&{of}\5
\\{integer};\C{used to locate asterisks if showing pattern}\2\6
\4\\{btab}: \37\&{array} $[0\to8]$ \1\&{of}\5
\\{integer};\C{used to define bits to blacken}\2\par
\fi
\M112. \P$\X11:Set initial values\X\mathrel{+}\S$\6
$\\{atab}[1]\K128$;\5
$\\{btab}[0]\K255$;\6
\&{for} $\|i\K2\mathrel{\&{to}}8$ \1\&{do}\5
$\\{atab}[\|i]\K\\{atab}[\|i-1]\mathbin{\&{div}}2$;\2\6
\&{for} $\|i\K1\mathrel{\&{to}}8$ \1\&{do}\5
$\\{btab}[\|i]\K\\{btab}[\|i-1]\mathbin{\&{div}}2$;\2\par
\fi
\M113. We will also have occasion to read halfwords from \\{mm\_store}.
\Y\P\4\&{function}\1\ \37$\\{read\_signed\_pair}(\\{mm\_tmp}:\\{integer})$: %
\37\\{integer};\C{returns the next two bytes, signed}\6
\4\&{var} \37$\|a,\39\|b$: \37\\{eight\_bits};\5
$\\{m1\_tmp},\39\\{m2\_tmp}$: \37\\{integer};\2\6
\&{begin} \37$\\{m1\_tmp}\K\\{mm\_tmp}\mathbin{\&{div}}(\\{m2\_size})$;\5
$\\{m2\_tmp}\K\\{mm\_tmp}\mathbin{\&{mod}}(\\{m2\_size})$;\5
$\|a\K\\{mm\_store}[\\{m1\_tmp},\39\\{m2\_tmp}]$;\6
\&{if} $\\{m2\_tmp}<\\{m2\_max}$ \1\&{then}\5
$\\{incr}(\\{m2\_tmp})$\6
\4\&{else} \&{begin} \37$\\{m2\_tmp}\K4$;\6
\&{if} $\\{m1\_tmp}<\\{m1\_max}$ \1\&{then}\5
$\\{incr}(\\{m1\_tmp})$\6
\4\&{else} $\\{m1\_tmp}\K0$;\C{wrap-around assumed}\2\6
\&{end};\2\6
$\|b\K\\{mm\_store}[\\{m1\_tmp},\39\\{m2\_tmp}]$;\6
\&{if} $\|a<128$ \1\&{then}\5
$\\{read\_signed\_pair}\K(\|a\ast256)+\|b$\6
\4\&{else} $\\{read\_signed\_pair}\K(\|a-256)\ast256+\|b$;\2\6
\&{end};\par
\fi
\M114. For debugging purposes it may be desirable to display the actual glyph
raster while it is being downloaded.
\Y\P\4\&{procedure}\1\ \37$\\{show\_it}(\|v:\\{integer})$;\6
\4\&{var} \37\|i: \37\\{integer};\2\6
\&{begin} \37\&{for} $\|i\K1\mathrel{\&{to}}8$ \1\&{do}\6
\&{if} $\|v\G\\{atab}[\|i]$ \1\&{then}\6
\&{begin} \37$\\{print}(\.{\'*\'})$;\5
$\|v\K\|v-\\{atab}[\|i]$;\6
\&{end}\6
\4\&{else} $\\{print}(\.{\'.\'})$;\2\2\6
\&{end};\par
\fi
\M115. And here is the procedure that does the actual downloading.
\Y\P\4\&{procedure}\1\ \37$\\{do\_im\_bgly}(\|c:\\{integer})$;\6
\4\&{var} \37$\|b,\39\\{dis},\39\|n,\39\|i,\39\|q,\39\\{val},\39\|w,\39\\{real%
\_w}$: \37\\{integer};\5
$\\{q1},\39\\{q2}$: \37\\{integer};\5
\\{bytes\_required}: \37\\{integer};\C{bytes per row for current glyph}\2\6
\&{begin} \37$\\{im\_byte}(\\{im\_bgly})$;\6
\&{if} $\|c<128$ \1\&{then}\5
$\\{im\_halfword}(\\{cur\_font}\ast128+\|c)$\C{normal family and member name}\6
\4\&{else} $\\{im\_halfword}(\\{im\_extension}[\\{cur\_font}]\ast128+\|c-128)$;%
\C{Imagen's family and member name}\2\6
$\|q\K\\{pixel\_width}[\\{data\_base}[\\{cur\_font}]+\|c]$;\5
$\\{im\_halfword}(\|q)$;\C{advance width}\6
$\|q\K\\{glyph\_ptr}[\\{data\_base}[\\{cur\_font}]+\|c]$;\C{get starting
location in \\{mm\_store}}\6
$\\{q1}\K\|q\mathbin{\&{div}}(\\{m2\_size})$;\5
$\\{q2}\K\|q\mathbin{\&{mod}}(\\{m2\_size})$;\6
\&{debug} \37$\\{print}(\.{\'\ \ \ im(\'},\39\\{cur\_font}:1,\39\.{\')\'},\39%
\|c:1,\39\.{\'[\'},\39\\{q1}:1,\39\.{\',\'},\39\\{q2}:1,\39\.{\']\'})$;\6
\&{gubed}\6
$\\{bytes\_required}\K((\\{read\_signed\_pair}(\|q)+7)\mathbin{\&{div}}8)$;\6
\&{for} $\|i\K1\mathrel{\&{to}}8$ \1\&{do}\6
\&{begin} \37$\\{im\_byte}(\\{mm\_store}[\\{q1},\39\\{q2}])$;\5
\\{advance\_q};\6
\&{end};\C{width, left offset, height,top offset}\2\6
$\|n\K0$;\5
$\\{dis}\K0$;\5
$\\{val}\K0$;\5
$\|w\K0$;\5
$\\{real\_w}\K0$;\6
\&{while} $\\{real\_w}\I\\{eoc}$ \1\&{do}\6
\&{begin} \37\X116:Translate a sequence of paint commands\X;\6
$\|w\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\5
$\\{real\_w}\K\|w$;\6
\&{if} $(\|w\G\\{new\_row\_0})\W(\|w\L\\{new\_row\_164})$ \1\&{then}\5
\X117:Translate a \\{new\_row} command\X\6
\4\&{else} \&{if} $(\|w\G\\{skip0})\W(\|w<\\{new\_row\_0})$ \1\&{then}\5
\X118:Translate a \\{skip} command\X\6
\4\&{else} \&{if} $\\{real\_w}\I\\{eoc}$ \1\&{then}\5
$\\{print\_ln}(\.{\'BAD\ D\ L\ COM\ \'},\39\|w:1,\39\.{\'\ (\'},\39\\{cur%
\_font}:1,\39\.{\')\'},\39\|c:1,\39\.{\'[\'},\39\\{q1}:1,\39\.{\',\'},\39%
\\{q2}:1,\39\.{\']\'})$;\2\2\2\6
\&{end};\C{$\\{print\_ln}(\.{\'G\ EOC\'})$;}\2\6
$\\{glyph\_ptr}[\\{data\_base}[\\{cur\_font}]+\|c]\K-\\{glyph\_ptr}[\\{data%
\_base}[\\{cur\_font}]+\|c]$;\C{to show that the glyph has been downloaded}\6
\&{end};\par
\fi
\M116. \P$\X116:Translate a sequence of paint commands\X\S$\6
\&{while} $\|n<\\{bytes\_required}$ \1\&{do}\6
\&{begin} \37\&{if} $\\{dis}=0$ \1\&{then}\6
\&{begin} \37\X119:Get two paint commands\X;\6
$\\{dis}\K\|w+\|b$;\6
\&{end};\2\6
\&{while} $\\{dis}<8$ \1\&{do}\6
\&{begin} \37$\\{val}\K\\{val}+\\{btab}[\|w]-\\{btab}[\\{dis}]$;\5
\X119:Get two paint commands\X;\6
$\|w\K\\{dis}+\|w$;\5
$\\{dis}\K\|w+\|b$;\6
\&{end};\2\6
\&{if} $\|w\G8$ \1\&{then}\5
$\|w\K\|w-8$\6
\4\&{else} \&{begin} \37$\\{val}\K\\{val}+\\{btab}[\|w]$;\5
$\|w\K0$;\6
\&{end};\2\6
$\\{im\_byte}(\\{val})$;\5
$\\{dis}\K\\{dis}-8$;\5
$\\{val}\K0$;\5
$\\{incr}(\|n)$;\6
\&{end}\2\par
\U section~115.\fi
\M117. \P$\X117:Translate a \\{new\_row} command\X\S$\6
\&{begin} \37$\|w\K\|w-\\{new\_row\_0}$;\5
\\{advance\_q};\5
$\|b\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\6
\&{if} $\|b\L\\{paint2}$ \1\&{then}\6
\&{begin} \37\\{advance\_q};\6
\&{if} $\|b=\\{paint2}$ \1\&{then}\6
\&{begin} \37$\|b\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\5
\\{advance\_q};\5
$\|b\K\|b\ast256+\\{mm\_store}[\\{q1},\39\\{q2}]$;\5
\\{advance\_q};\6
\&{end}\6
\4\&{else} \&{if} $\|b=\\{paint1}$ \1\&{then}\6
\&{begin} \37$\|b\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\5
\\{advance\_q};\6
\&{end};\2\2\6
$\|n\K0$;\5
$\\{dis}\K\|w+\|b$;\5
$\\{val}\K0$;\6
\&{end}\6
\4\&{else} \&{begin} \37$\|b\K0$;\5
$\|w\K8\ast\\{bytes\_required}$;\C{a safety measure}\6
\&{end};\2\6
$\|n\K0$;\5
$\\{dis}\K\|w+\|b$;\5
$\\{val}\K0$;\6
\&{end}\par
\U section~115.\fi
\M118. \P$\X118:Translate a \\{skip} command\X\S$\6
\&{begin} \37\&{if} $\|w>\\{skip0}$ \1\&{then}\6
\&{begin} \37\\{advance\_q};\5
$\|w\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\6
\&{while} $\|w>0$ \1\&{do}\6
\&{begin} \37\&{for} $\|n\K1\mathrel{\&{to}}\\{bytes\_required}$ \1\&{do}\5
$\\{im\_byte}(0)$;\2\6
$\\{decr}(\|w)$;\6
\&{end};\2\6
\&{end};\2\6
\\{advance\_q};\5
$\|n\K0$;\5
$\\{dis}\K0$;\5
$\\{val}\K0$;\5
$\|w\K0$;\5
$\|b\K0$;\6
\&{end}\par
\U section~115.\fi
\M119. \P$\X119:Get two paint commands\X\S$\6
\&{begin} \37$\|w\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\6
\&{if} $\|w\L\\{paint2}$ \1\&{then}\6
\&{begin} \37\&{if} $\|w=\\{paint2}$ \1\&{then}\6
\&{begin} \37\\{advance\_q};\5
$\|w\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\5
\\{advance\_q};\5
$\|w\K\|w\ast256+\\{mm\_store}[\\{q1},\39\\{q2}]$;\C{can be as high as 65535}\6
\&{end}\6
\4\&{else} \&{if} $\|w=\\{paint1}$ \1\&{then}\6
\&{begin} \37\\{advance\_q};\5
$\|w\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\C{can be between 64 and 255}\6
\&{end};\2\2\6
\\{advance\_q};\5
$\|b\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\6
\&{if} $\|b\L\\{paint2}$ \1\&{then}\6
\&{begin} \37\&{if} $\|b=\\{paint2}$ \1\&{then}\6
\&{begin} \37\\{advance\_q};\5
$\|b\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\5
\\{advance\_q};\5
$\|b\K\|b\ast256+\\{mm\_store}[\\{q1},\39\\{q2}]$;\6
\&{end}\6
\4\&{else} \&{if} $\|b=\\{paint1}$ \1\&{then}\6
\&{begin} \37\\{advance\_q};\5
$\|b\K\\{mm\_store}[\\{q1},\39\\{q2}]$;\6
\&{end};\2\2\6
\\{advance\_q};\6
\&{end}\6
\4\&{else} \&{begin} \37$\|b\K0$;\5
$\|w\K8\ast\\{bytes\_required}$;\C{a safety measure}\6
\&{end};\2\6
\&{end}\6
\4\&{else} \&{begin} \37$\|b\K0$;\5
$\|w\K8\ast\\{bytes\_required}$;\C{a safety measure}\6
\&{end};\2\6
\&{end}\par
\U sections~116 and~116.\fi
\N120. Translation to Impress form.
The main work of \.{DVIIMP} is accomplished by the \\{do\_page} procedure,
which produces the output for an entire page, assuming that the \\{bop}
command for that page has already been processed. This procedure is
essentially an interpretive routine that reads and acts on the \.{DVI}
commands.
\fi
\M121. The definition of \.{DVI} files refers to six registers,
$(h,v,w,x,y,z)$, which hold integer values in \.{DVI} units. In practice,
we also need registers \\{hh} and \\{vv}, the pixel analogs of $h$ and $v$,
since it is not always true that $\\{hh}=\\{pixel\_round}(\|h)$ or
$\\{vv}=\\{pixel\_round}(\|v)$. We will also find it useful to have two other
registers, \\{hhi} and \\{vvi}
to hold the values that \.{IMAGEN} would automatically
assign for for the horizontal and vertical locations.
The stack of $(h,v,w,x,y,z)$ values is represented by eight arrays
called \\{hstack}, \dots, \\{zstack}, \\{hhstack}, and \\{vvstack}.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4$\|h,\39\|v,\39\|w,\39\|x,\39\|y,\39\|z,\39\\{hh},\39\\{hhi},\39\\{vv},\39%
\\{vvi}$: \37\\{integer};\C{current state values}\6
\4$\\{hstack},\39\\{vstack},\39\\{wstack},\39\\{xstack},\39\\{ystack},\39%
\\{zstack}$: \37\&{array} $[0\to\\{stack\_size}]$ \1\&{of}\5
\\{integer};\C{pushed down values in \.{DVI} units}\2\6
\4$\\{hhstack},\39\\{vvstack}$: \37\&{array} $[0\to\\{stack\_size}]$ \1\&{of}\5
\\{integer};\C{pushed down values in pixels}\2\par
\fi
\M122. Three characteristics of the pages (their \\{max\_v}, \\{max\_h}, and
\\{max\_s}) are specified in the postamble.
Only \\{max\_s} should not be exceeded.
The postamble also specifies the total number of pages.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{max\_v}: \37\\{integer};\C{the value of $\\{abs}(\|v)$ should probably not
exceed this}\6
\4\\{max\_h}: \37\\{integer};\C{the value of $\\{abs}(\|h)$ should probably not
exceed this}\6
\4\\{max\_s}: \37\\{integer};\C{the stack depth should not exceed this}\6
\4\\{max\_s\_so\_far}: \37\\{integer};\C{the record high levels}\6
\4\\{total\_pages}: \37\\{integer};\C{the stated total number of pages}\par
\fi
\M123. \P$\X11:Set initial values\X\mathrel{+}\S$\6
$\\{max\_s}\K\\{stack\_size}+1$;\5
$\\{max\_s\_so\_far}\K0$;\par
\fi
\M124. Before we get into the details of \\{do\_page}, it is convenient to
consider a simpler routine that computes the first parameter of each
opcode. In doing this, we will use some multiple-case terms that were
defined earlier.
\Y\P\4\&{function}\1\ \37$\\{first\_par}(\|o:\\{eight\_bits})$: \37%
\\{integer};\2\6
\&{begin} \37\&{case} $\|o$ \1\&{of}\6
\4$\\{sixty\_four\_cases}(\\{set\_char\_0}),\39\\{sixty\_four\_cases}(\\{set%
\_char\_0}+64)$: \37$\\{first\_par}\K\|o-\\{set\_char\_0}$;\6
\4$\\{set1},\39\\{put1},\39\\{fnt1},\39\\{xxx1},\39\\{fnt\_def1}$: \37$\\{first%
\_par}\K\\{get\_byte}$;\6
\4$\\{set1}+1,\39\\{put1}+1,\39\\{fnt1}+1,\39\\{xxx1}+1,\39\\{fnt\_def1}+1$: %
\37$\\{first\_par}\K\\{get\_two\_bytes}$;\6
\4$\\{set1}+2,\39\\{put1}+2,\39\\{fnt1}+2,\39\\{xxx1}+2,\39\\{fnt\_def1}+2$: %
\37$\\{first\_par}\K\\{get\_three\_bytes}$;\6
\4$\\{right1},\39\\{w1},\39\\{x1},\39\\{down1},\39\\{y1},\39\\{z1}$: \37$%
\\{first\_par}\K\\{signed\_byte}$;\6
\4$\\{right1}+1,\39\\{w1}+1,\39\\{x1}+1,\39\\{down1}+1,\39\\{y1}+1,\39%
\\{z1}+1$: \37$\\{first\_par}\K\\{signed\_pair}$;\6
\4$\\{right1}+2,\39\\{w1}+2,\39\\{x1}+2,\39\\{down1}+2,\39\\{y1}+2,\39%
\\{z1}+2$: \37$\\{first\_par}\K\\{signed\_trio}$;\6
\4$\\{set1}+3,\39\\{set\_rule},\39\\{put1}+3,\39\\{put\_rule},\39\\{right1}+3,%
\39\\{w1}+3,\39\\{x1}+3,\39\\{down1}+3,\39\\{y1}+3,\39\\{z1}+3,\39\\{fnt1}+3,%
\39\\{xxx1}+3,\39\\{fnt\_def1}+3$: \37$\\{first\_par}\K\\{signed\_quad}$;\6
\4$\\{nop},\39\\{bop},\39\\{eop},\39\\{push},\39\\{pop},\39\\{pre},\39\\{post},%
\39\\{post\_post},\39\\{undefined\_commands}$: \37$\\{first\_par}\K0$;\6
\4\\{w0}: \37$\\{first\_par}\K\|w$;\6
\4\\{x0}: \37$\\{first\_par}\K\|x$;\6
\4\\{y0}: \37$\\{first\_par}\K\|y$;\6
\4\\{z0}: \37$\\{first\_par}\K\|z$;\6
\4$\\{sixty\_four\_cases}(\\{fnt\_num\_0})$: \37$\\{first\_par}\K\|o-\\{fnt%
\_num\_0}$;\2\6
\&{end};\6
\&{end};\par
\fi
\M125. Here is another subroutine that we need: It computes the number of
pixels in the height or width of a rule. Characters and rules will line up
properly if the sizes are computed precisely as specified here. (Since
\\{conv} is computed with some floating-point roundoff error, in a
machine-dependent way, format designers who are tailoring something for a
particular resolution should not plan their measurements to come out to an
exact integer number of pixels; they should compute things so that the
rule dimensions are a little less than an integer number of pixels, e.g.,
4.99 instead of 5.00.)
\Y\P\4\&{function}\1\ \37$\\{rule\_pixels}(\|x:\\{integer})$: \37\\{integer};%
\C{computes $\lceil\\{conv}\cdot x\rceil$}\6
\4\&{var} \37\|n: \37\\{integer};\2\6
\&{begin} \37$\|n\K\\{trunc}(\\{conv}\ast\|x)$;\6
\&{if} $\|n<\\{conv}\ast\|x$ \1\&{then}\5
$\\{rule\_pixels}\K\|n+1$\ \&{else} $\\{rule\_pixels}\K\|n$;\2\6
\&{end};\par
\fi
\M126. The \\{do\_page}
subroutine is organized as a typical interpreter, with a multiway branch
on the command code followed by \&{goto} statements leading to routines that
finish up the activities common to different commands. We will use the
following labels:
\Y\P\D \37$\\{fin\_set}=41$\C{label for commands that set or put a character}%
\par
\P\D \37$\\{fin\_rule}=42$\C{label for commands that set or put a rule}\par
\P\D \37$\\{move\_right}=43$\C{label for commands that change \|h}\par
\P\D \37$\\{move\_down}=44$\C{label for commands that change \|v}\par
\P\D \37$\\{change\_font}=45$\C{label for commands that change \\{cur\_font}}%
\par
\fi
\M127. Some \PASCAL\ compilers severely restrict the length of procedure
bodies,
so we shall split \\{do\_page} into two parts, one of which is
called \\{special\_cases}. The different parts communicate with each other
via the global variables mentioned above, together with the following ones:
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\|s: \37\\{integer};\C{current stack size}\6
\4\\{cur\_font}: \37\\{integer};\C{current internal font number}\par
\fi
\M128. Here is the overall setup.
\Y\P\D \37$\\{infinity}\S\O{17777777777}$\C{$\infty$ (approximately)}\par
\Y\P\hbox{\4}\X132:Declare the function called \\{special\_cases}\X\6
\4\&{procedure}\1\ \37\\{do\_page};\6
\4\&{label} \37$\\{fin\_set},\39\\{fin\_rule},\39\\{move\_right},\39\\{done},%
\399999$;\6
\4\&{var} \37\|o: \37\\{eight\_bits};\C{operation code of the current command}\6
$\|p,\39\|q$: \37\\{integer};\C{parameters of the current command}\6
\|g: \37\\{integer};\C{to hold \\{glyph\_ptr} temporarily and force its
computation}\6
\|a: \37\\{integer};\C{byte number of the current command}\6
\\{hhh}: \37\\{integer};\C{\|h, rounded to the nearest pixel}\2\6
\&{begin} \37$\\{cur\_font}\K\\{nf}$;\C{set current font undefined}\6
$\|s\K0$;\5
$\|h\K\\{round}(300/\\{conv})$;\5
$\|v\K\|h$;\5
$\|w\K0$;\5
$\|x\K0$;\5
$\|y\K0$;\5
$\|z\K0$;\5
$\\{hh}\K\\{pixel\_round}(\|h)$;\5
$\\{vv}\K\\{pixel\_round}(\|v)$;\5
$\\{hhi}\K\\{infinity}$;\5
$\\{vvi}\K\\{infinity}$;\C{initialize the state variables}\6
\&{while} $\\{true}$ \1\&{do}\5
\X130:Translate the next command in the \.{DVI} file; \&{goto} 9999 if it was %
\\{eop}\X;\2\6
\49999: \37$\\{im\_byte}(\\{im\_end\_page})$;\6
\&{end};\par
\fi
\M129. The following routine allows us to read the pages in reverse order.
\Y\P\4\&{procedure}\1\ \37\\{next\_page};\6
\4\&{var} \37\|p: \37\\{integer};\C{a parameter}\6
\|k: \37$0\to255$;\C{command code}\2\6
\&{begin} \37$\\{move\_to\_byte}(\\{new\_backpointer})$;\5
$\|k\K\\{get\_byte}$;\6
\&{if} $\|k=\\{bop}$ \1\&{then}\6
\&{begin} \37\&{for} $\|k\K0\mathrel{\&{to}}9$ \1\&{do}\5
$\\{count}[\|k]\K\\{signed\_quad}$;\2\6
$\\{new\_backpointer}\K\\{signed\_quad}$;\6
\&{debug} \37$\\{print\_ln}(\.{\'\ In\ next\_page\ first\_backpointer=\'},\39%
\\{first\_backpointer}:1)$;\6
\&{gubed}\6
\&{end};\2\6
\&{if} $(\\{abs}(\\{count}[0])\L\\{last\_page})\W(\\{abs}(\\{count}[0])\G%
\\{start\_page})$ \1\&{then}\6
\&{begin} \37\\{do\_page};\5
$\\{print}(\.{\'[\'},\39\\{count}[0]:1,\39\.{\']\ \'})$;\6
\&{end};\2\6
\&{end};\par
\fi
\M130. The main command loop.
\Y\P$\4\X130:Translate the next command in the \.{DVI} file; \&{goto} 9999 if
it was \\{eop}\X\S$\6
\&{begin} \37$\|a\K\\{cur\_loc}$;\5
$\|o\K\\{get\_byte}$;\5
$\|p\K\\{first\_par}(\|o)$;\6
\&{if} $\\{eof}(\\{dvi\_file})$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'the\ file\ ended\ prematurely\'})$;\2\6
\X131:Start translation of command \|o and \&{goto} the appropriate label to
finish the job\X;\6
\4\\{fin\_set}: \37\X139:Finish a command that either sets or puts a character,
then \&{goto} \\{move\_right} or \\{done}\X;\6
\4\\{fin\_rule}: \37\X140:Finish a command that either sets or puts a rule,
then \&{goto} \\{move\_right} or \\{done}\X;\6
\4\\{move\_right}: \37\X141:Finish a command that sets $\|h\K\|h+\|q$, then %
\&{goto} \\{done}\X;\6
\4\\{done}: \37\&{end}\par
\U section~128.\fi
\M131. The multiway switch in \\{first\_par}, above, was organized by the
length
of each command; the one in \\{do\_page} is organized by the semantics.
\Y\P$\4\X131:Start translation of command \|o and \&{goto} the appropriate
label to finish the job\X\S$\6
\&{if} $\|o<\\{set\_char\_0}+128$ \1\&{then}\5
\&{goto} \37\\{fin\_set}\6
\4\&{else} \&{case} $\|o$ \1\&{of}\6
\4$\\{four\_cases}(\\{set1})$: \37\&{goto} \37\\{fin\_set};\6
\4$\\{four\_cases}(\\{put1})$: \37\&{goto} \37\\{fin\_set};\6
\4\\{set\_rule}: \37\&{goto} \37\\{fin\_rule};\6
\4\\{put\_rule}: \37\&{goto} \37\\{fin\_rule};\6
\hbox{\4}\X133:Cases for commands \\{nop}, \\{bop}, \dots, \\{pop}\X\6
\hbox{\4}\X134:Cases for horizontal motion\X\6
\4\&{othercases} \37\&{begin} \37$\\{special\_cases}(\|o,\39\|p,\39\|a)$;\5
\&{goto} \37\\{done};\6
\&{end}\2\6
\&{endcases}\2\par
\U section~130.\fi
\M132. \P$\X132:Declare the function called \\{special\_cases}\X\S$\6
\4\&{procedure}\1\ \37$\\{special\_cases}(\|o:\\{eight\_bits};\,\35\|p,\39\|a:%
\\{integer})$;\6
\4\&{label} \37$\\{change\_font},\39\\{move\_down},\39\\{done}$;\6
\4\&{var} \37\|q: \37\\{integer};\C{parameter of the current command}\6
\|k: \37\\{integer};\C{loop index}\6
\\{bad\_char}: \37\\{boolean};\C{has a non-ASCII character code appeared in
this \\{xxx}?}\6
\\{vvv}: \37\\{integer};\C{\|v, rounded to the nearest pixel}\2\6
\&{begin} \37\&{case} $\|o$ \1\&{of}\6
\hbox{\4}\X135:Cases for vertical motion\X\6
\hbox{\4}\X136:Cases for fonts\X\6
\4$\\{four\_cases}(\\{xxx1})$: \37\X137:Translate an \\{xxx} command and %
\&{goto} \\{done}\X;\6
\4\\{pre}: \37$\\{bad\_dvi}(\.{\'preamble\ command\ within\ a\ page!\'})$;\6
\4$\\{post},\39\\{post\_post}$: \37$\\{bad\_dvi}(\.{\'postamble\ command\
within\ a\ page!\'})$;\6
\4\&{othercases} \37$\\{bad\_dvi}(\.{\'undefined\ command\ \'},\39\|o:1,\39\.{%
\'!\'})$\2\6
\&{endcases};\6
\4\\{move\_down}: \37\X142:Finish a command that sets $\|v\K\|v+\|p$, then %
\&{goto} \\{done}\X;\6
\4\\{change\_font}: \37\X143:Finish a command that changes the current font,
then \&{goto} \\{done}\X;\6
\4\\{done}: \37\&{end};\par
\U section~128.\fi
\M133. \P$\X133:Cases for commands \\{nop}, \\{bop}, \dots, \\{pop}\X\S$\6
\4\\{nop}: \37\&{goto} \37\\{done};\6
\4\\{bop}: \37$\\{bad\_dvi}(\.{\'bop\ occurred\ before\ eop!\'})$;\6
\4\\{eop}: \37\&{begin} \37\&{if} $\|s\I0$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'stack\ not\ empty\ at\ end\ of\ page\ (level\ \'},\39\|s:1,%
\39\.{\')!\'})$;\2\6
\&{goto} \379999;\6
\&{end};\6
\4\\{push}: \37\&{begin} \37\&{if} $\|s=\\{max\_s\_so\_far}$ \1\&{then}\6
\&{begin} \37$\\{max\_s\_so\_far}\K\|s+1$;\6
\&{if} $\|s=\\{max\_s}$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'deeper\ than\ claimed\ in\ postamble!\'})$;\2\6
\&{if} $\|s=\\{stack\_size}$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'DVIIMP\ capacity\ exceeded\ (stack\ size=\'},\39\\{stack%
\_size}:1,\39\.{\')\'})$;\2\6
\&{end};\2\6
$\\{hstack}[\|s]\K\|h$;\5
$\\{vstack}[\|s]\K\|v$;\5
$\\{wstack}[\|s]\K\|w$;\5
$\\{xstack}[\|s]\K\|x$;\5
$\\{ystack}[\|s]\K\|y$;\5
$\\{zstack}[\|s]\K\|z$;\5
$\\{hhstack}[\|s]\K\\{hh}$;\5
$\\{vvstack}[\|s]\K\\{vv}$;\5
$\\{incr}(\|s)$;\5
\&{goto} \37\\{done};\6
\&{end};\6
\4\\{pop}: \37\&{begin} \37\&{if} $\|s=0$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'POP\ illegal\ at\ level\ zero\'})$\6
\4\&{else} \&{begin} \37$\\{decr}(\|s)$;\5
$\\{hh}\K\\{hhstack}[\|s]$;\5
$\\{vv}\K\\{vvstack}[\|s]$;\5
$\|h\K\\{hstack}[\|s]$;\5
$\|v\K\\{vstack}[\|s]$;\5
$\|w\K\\{wstack}[\|s]$;\5
$\|x\K\\{xstack}[\|s]$;\5
$\|y\K\\{ystack}[\|s]$;\5
$\|z\K\\{zstack}[\|s]$;\6
\&{end};\2\6
\&{goto} \37\\{done};\6
\&{end};\par
\U section~131.\fi
\M134. Rounding to the nearest pixel is best done in the manner shown here, so
as
to be inoffensive to the eye: When the horizontal motion is small, like a
kern, \\{hh} changes by rounding the kern; but when the motion is large, \\{hh}
changes by rounding the true position \|h so that accumulated rounding errors
disappear. We allow a larger space in the negative direction than in
the positive one, because \TeX\ makes comparatively
large backspaces when it positions accents.
\Y\P\D \37$\\{out\_space}\S$\1\6
\&{if} $(\|p\G\\{font\_space}[\\{cur\_font}])\V(\|p\L-4\ast\\{font\_space}[%
\\{cur\_font}])$ \1\&{then}\5
$\\{hh}\K\\{pixel\_round}(\|h+\|p)$\6
\4\&{else} $\\{hh}\K\\{hh}+\\{pixel\_round}(\|p)$;\2\2\6
$\|q\K\|p$;\5
\&{goto} \37\\{move\_right}\par
\Y\P$\4\X134:Cases for horizontal motion\X\S$\6
\4$\\{four\_cases}(\\{right1})$: \37\&{begin} \37\\{out\_space};\6
\&{end};\6
\4$\\{w0},\39\\{four\_cases}(\\{w1})$: \37\&{begin} \37$\|w\K\|p$;\5
\\{out\_space};\6
\&{end};\6
\4$\\{x0},\39\\{four\_cases}(\\{x1})$: \37\&{begin} \37$\|x\K\|p$;\5
\\{out\_space};\6
\&{end};\par
\U section~131.\fi
\M135. Vertical motion is done similarly, but with the threshold between
``small'' and ``large'' increased by a factor of five. The idea is to make
fractions like ``$1\over2$'' round consistently, but to absorb accumulated
rounding errors in the baseline-skip moves.
\Y\P\D \37$\\{out\_vmove}\S$\1\6
\&{if} $\\{abs}(\|p)\G5\ast\\{font\_space}[\\{cur\_font}]$ \1\&{then}\5
$\\{vv}\K\\{pixel\_round}(\|v+\|p)$\6
\4\&{else} $\\{vv}\K\\{vv}+\\{pixel\_round}(\|p)$;\2\2\6
\&{goto} \37\\{move\_down}\par
\Y\P$\4\X135:Cases for vertical motion\X\S$\6
\4$\\{four\_cases}(\\{down1})$: \37\&{begin} \37\\{out\_vmove};\6
\&{end};\6
\4$\\{y0},\39\\{four\_cases}(\\{y1})$: \37\&{begin} \37$\|y\K\|p$;\5
\\{out\_vmove};\6
\&{end};\6
\4$\\{z0},\39\\{four\_cases}(\\{z1})$: \37\&{begin} \37$\|z\K\|p$;\5
\\{out\_vmove};\6
\&{end};\par
\U section~132.\fi
\M136. \P$\X136:Cases for fonts\X\S$\6
\4$\\{sixty\_four\_cases}(\\{fnt\_num\_0})$: \37\&{goto} \37\\{change\_font};\6
\4$\\{four\_cases}(\\{fnt1})$: \37\&{goto} \37\\{change\_font};\6
\4$\\{four\_cases}(\\{fnt\_def1})$: \37\&{begin} \37\\{skip\_it};\5
\&{goto} \37\\{done};\6
\&{end};\par
\U section~132.\fi
\M137. \P$\X137:Translate an \\{xxx} command and \&{goto} \\{done}\X\S$\6
\&{begin} \37$\\{bad\_char}\K\\{false}$;\6
\&{if} $\|p<0$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'string\ of\ negative\ length!\'})$;\2\6
\&{for} $\|k\K1\mathrel{\&{to}}\|p$ \1\&{do}\6
\&{begin} \37$\|q\K\\{get\_byte}$;\6
\&{if} $(\|q<\.{"\ "})\V(\|q>\.{"\~"})$ \1\&{then}\5
$\\{bad\_char}\K\\{true}$;\2\6
\&{end};\2\6
\&{if} $\\{bad\_char}$ \1\&{then}\5
$\\{print}(\.{\'non-ASCII\ character\ in\ xxx\ command!\'})$;\2\6
\&{goto} \37\\{done};\6
\&{end}\par
\U section~132.\fi
\M138. \P$\X138:Resyncronize\X\S$\6
\&{if} $\\{hhi}\I\\{hh}$ \1\&{then}\6
\&{begin} \37\&{debug} \37$\\{print}(\.{\'\ \ \'},\39\\{hhi}:1,\39\.{\',\'},\39%
\\{hh}:1)$;\6
\&{gubed}$\\{hhi}\K\\{hh}$;\5
$\\{im\_byte}(\\{set\_abs\_h})$;\5
$\\{im\_halfword}(\\{hh})$;\6
\&{end};\2\6
\&{if} $\\{vvi}\I\\{vv}$ \1\&{then}\6
\&{begin} \37$\\{vvi}\K\\{vv}$;\5
$\\{im\_byte}(\\{set\_abs\_v})$;\5
$\\{im\_halfword}(\\{vv})$;\6
\&{end};\2\par
\U sections~139, 139, and~140.\fi
\M139. \P$\X139:Finish a command that either sets or puts a character, then %
\&{goto} \\{move\_right} or \\{done}\X\S$\6
\&{if} $\|p<0$ \1\&{then}\5
$\|p\K255-((-1-\|p)\mathbin{\&{mod}}256)$\6
\4\&{else} \&{if} $\|p\G256$ \1\&{then}\5
$\|p\K\|p\mathbin{\&{mod}}256$;\C{width computation for oriental fonts}\6
\C{ \&{if} $(\|p<\\{font\_bc}[\\{cur\_font}])\V(\|p>\\{font\_ec}[\\{cur%
\_font}])$ \&{then} $\|q\K\\{invalid\_width}$ \&{else} }\2\2\6
$\|q\K\\{char\_width}(\\{cur\_font})(\|p)$;\6
\&{debug} \37$\\{print\_ln}(\.{\'\ p=\'},\39\|p:1)$;\5
$\\{print\_ln}(\.{\'\ bc=\'},\39\\{font\_bc}[\\{cur\_font}]:1,\39\.{\'\ ec=\'},%
\39\\{font\_ec}[\\{cur\_font}]:1)$;\5
$\\{print}(\.{\'\ ch\'},\39\\{char\_width}(\\{cur\_font})(\|p):1)$;\5
$\\{print\_ln}(\.{\'\ q=\'},\39\|q:1)$;\6
\&{gubed}\6
\&{if} $\|q=\\{invalid\_width}$ \1\&{then}\6
\&{begin} \37$\\{print}(\.{\'character\ \'},\39\|p:1,\39\.{\'\ invalid\ in\
font\ \'})$;\5
$\\{print\_font}(\\{cur\_font})$;\6
\&{if} $\\{cur\_font}\I\\{nf}$ \1\&{then}\5
$\\{print}(\.{\'!\'})$;\C{font \\{nf} has `\.!' in its name}\2\6
\&{end}\6
\4\&{else} \&{begin} \37$\|g\K\\{glyph\_ptr}[\\{data\_base}[\\{cur\_font}]+%
\|p]$;\6
\&{debug} \37\&{if} $\|g<-3$ \1\&{then}\5
$\\{print}(\.{\'\ (\'},\39\\{cur\_font}:1,\39\.{\')\'},\39\|p:1)$;\2\6
\&{gubed}\6
\&{if} $\|g=0$ \1\&{then}\6
\&{begin} \37\&{debug} \37$\\{print\_ln}(\.{\'\ must\ reload\ (\'},\39\\{cur%
\_font}:1,\39\.{\')\'},\39\|p:1)$;\6
\&{gubed}\\{reload\_font};\C{font must be reloaded}\6
$\|g\K\\{glyph\_ptr}[\\{data\_base}[\\{cur\_font}]+\|p]$;\6
\&{end};\2\6
\&{debug} \37\&{if} $\|g=-1$ \1\&{then}\5
$\\{print}(\.{\'\ -1(\'},\39\\{cur\_font}:1,\39\.{\')\'},\39\|p:1)$;\2\6
\&{gubed}\6
\&{if} $\|g>3$ \1\&{then}\5
$\\{do\_im\_bgly}(\|p)$;\2\6
\X138:Resyncronize\X;\6
\&{if} $(\\{font\_state}[\\{cur\_font}]=2)\V(\|g=-1)$ \1\&{then}\6
\&{begin} \37$\\{hhi}\K\\{hhi}+\\{pixel\_width}[\\{data\_base}[\\{cur\_font}]+%
\|p]$;\5
\X138:Resyncronize\X;\6
\&{end}\6
\4\&{else} \&{begin} \37\&{if} $\|p<128$ \1\&{then}\5
$\\{im\_byte}(\|p)$\C{this sets or puts p of current family}\6
\4\&{else} \&{begin} \37$\\{im\_byte}(\\{set\_family})$;\5
$\\{im\_byte}(\\{im\_extension}[\\{cur\_font}])$;\5
$\\{im\_byte}(\|p-128)$;\C{this sets or puts glyph under its imagen name}\6
$\\{im\_byte}(\\{set\_family})$;\5
$\\{im\_byte}(\\{cur\_font})$;\6
\&{end};\2\6
$\\{hhi}\K\\{hhi}+\\{pixel\_width}[\\{data\_base}[\\{cur\_font}]+\|p]$;\6
\&{end};\2\6
\&{end};\2\6
\&{if} $\|o\G\\{put1}$ \1\&{then}\5
\&{goto} \37\\{done};\2\6
\&{if} $\|q=\\{invalid\_width}$ \1\&{then}\5
$\|q\K0$\6
\4\&{else} $\\{hh}\K\\{hh}+\\{char\_pixel\_width}(\\{cur\_font})(\|p)$;\2\6
\&{goto} \37\\{move\_right}\par
\U section~130.\fi
\M140. \P$\X140:Finish a command that either sets or puts a rule, then \&{goto}
\\{move\_right} or \\{done}\X\S$\6
$\|q\K\\{signed\_quad}$;\5
\X138:Resyncronize\X;\6
$\\{im\_byte}(\\{im\_brule})$;\5
$\\{im\_halfword}(\\{rule\_pixels}(\|q))$;\5
$\\{im\_halfword}(\\{rule\_pixels}(\|p))$;\5
$\\{im\_halfword}(\\{rule\_pixels}(-\|p))$;\6
\&{if} $\|o=\\{put\_rule}$ \1\&{then}\5
\&{goto} \37\\{done};\2\6
$\\{hh}\K\\{hh}+\\{rule\_pixels}(\|q)$;\5
\&{goto} \37\\{move\_right}\par
\U section~130.\fi
\M141. A sequence of consecutive rules, or consecutive characters in a
fixed-width
font whose width is not an integer number of pixels, can cause \\{hh} to drift
far away from a correctly rounded value. \.{DVIIMP} ensures that the
amount of drift will never exceed \\{max\_drift} pixels.
\Y\P\D \37$\\{max\_drift}=2$\C{we insist that abs$(\\{hh}-\\{pixel\_round}(%
\|h))\L\\{max\_drift}$}\par
\Y\P$\4\X141:Finish a command that sets $\|h\K\|h+\|q$, then \&{goto} \\{done}%
\X\S$\6
\&{if} $(\|h>0)\W(\|q>0)$ \1\&{then}\6
\&{if} $\|h>\\{infinity}-\|q$ \1\&{then}\6
\&{begin} \37$\\{print}(\.{\'arithmetic\ overflow!\ parameter\ changed\ from\ %
\'},\39\|q:1,\39\.{\'\ to\ \'},\39\\{infinity}-\|h:1)$;\5
$\|q\K\\{infinity}-\|h$;\6
\&{end};\2\2\6
\&{if} $(\|h<0)\W(\|q<0)$ \1\&{then}\6
\&{if} $-\|h>\|q+\\{infinity}$ \1\&{then}\6
\&{begin} \37$\\{print}(\.{\'arithmetic\ overflow!\ parameter\ changed\ from\ %
\'},\39\|q:1,\39\.{\'\ to\ \'},\39(-\|h)-\\{infinity}:1)$;\5
$\|q\K(-\|h)-\\{infinity}$;\6
\&{end};\2\2\6
$\\{hhh}\K\\{pixel\_round}(\|h+\|q)$;\6
\&{if} $\\{abs}(\\{hhh}-\\{hh})>\\{max\_drift}$ \1\&{then}\6
\&{begin} \37\&{if} $\\{hhh}>\\{hh}$ \1\&{then}\5
$\\{hh}\K\\{hhh}-\\{max\_drift}$\6
\4\&{else} $\\{hh}\K\\{hhh}+\\{max\_drift}$;\2\6
$\\{hhi}\K\\{hh}$;\5
$\\{im\_byte}(\\{set\_abs\_h})$;\5
$\\{im\_halfword}(\\{hhi})$;\6
\&{end};\2\6
$\|h\K\|h+\|q$;\5
\&{goto} \37\\{done}\par
\U section~130.\fi
\M142. \P$\X142:Finish a command that sets $\|v\K\|v+\|p$, then \&{goto} %
\\{done}\X\S$\6
\&{if} $(\|v>0)\W(\|p>0)$ \1\&{then}\6
\&{if} $\|v>\\{infinity}-\|p$ \1\&{then}\6
\&{begin} \37$\\{print}(\.{\'arithmetic\ overflow!\ parameter\ changed\ from\ %
\'},\39\|p:1,\39\.{\'\ to\ \'},\39\\{infinity}-\|v:1)$;\5
$\|p\K\\{infinity}-\|v$;\6
\&{end};\2\2\6
\&{if} $(\|v<0)\W(\|p<0)$ \1\&{then}\6
\&{if} $-\|v>\|p+\\{infinity}$ \1\&{then}\6
\&{begin} \37$\\{print}(\.{\'arithmetic\ overflow!\ parameter\ changed\ from\ %
\'},\39\|p:1,\39\.{\'\ to\ \'},\39(-\|v)-\\{infinity}:1)$;\5
$\|p\K(-\|v)-\\{infinity}$;\6
\&{end};\2\2\6
$\\{vvv}\K\\{pixel\_round}(\|v+\|p)$;\6
\&{if} $\\{abs}(\\{vvv}-\\{vv})>\\{max\_drift}$ \1\&{then}\6
\&{begin} \37\&{if} $\\{vvv}>\\{vv}$ \1\&{then}\5
$\\{vv}\K\\{vvv}-\\{max\_drift}$\6
\4\&{else} $\\{vv}\K\\{vvv}+\\{max\_drift}$;\2\6
$\\{vvi}\K\\{vv}$;\5
$\\{im\_byte}(\\{set\_abs\_v})$;\5
$\\{im\_halfword}(\\{vvi})$;\6
\&{end};\2\6
$\|v\K\|v+\|p$;\5
\&{goto} \37\\{done}\par
\U section~132.\fi
\M143. \P$\X143:Finish a command that changes the current font, then \&{goto} %
\\{done}\X\S$\6
$\\{font\_num}[\\{nf}]\K\|p$;\5
$\\{cur\_font}\K0$;\6
\&{while} $\\{font\_num}[\\{cur\_font}]\I\|p$ \1\&{do}\5
$\\{incr}(\\{cur\_font})$;\2\6
\&{if} $\\{cur\_font}=\\{nf}$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'bad\ font?\'})$;\2\6
\&{if} $\\{font\_state}[\\{cur\_font}]=0$ \1\&{then}\6
\&{begin} \37\\{get\_gf\_file};\6
\&{if} $\\{font\_state}[\\{cur\_font}]=0$ \1\&{then}\6
\&{begin} \37\&{if} $\\{in\_gf}(\\{font\_scaled\_size}[\\{cur\_font}])$ \1%
\&{then}\5
$\\{font\_state}[\\{cur\_font}]\K1$\6
\4\&{else} $\\{font\_state}[\\{cur\_font}]\K-1$;\2\6
\&{end};\2\6
\&{if} $\\{font\_state}[\\{cur\_font}]=2$ \1\&{then}\6
\&{begin} \37\&{if} $\\{in\_tfm}(\\{font\_scaled\_size}[\\{cur\_font}])$ \1%
\&{then}\5
$\\{font\_state}[\\{cur\_font}]\K2$\6
\4\&{else} $\\{font\_state}[\\{cur\_font}]\K-1$;\2\6
\&{end};\2\6
\&{end};\2\6
$\\{im\_byte}(\\{set\_family})$;\5
$\\{im\_byte}(\\{cur\_font})$;\5
\&{goto} \37\\{done}\par
\U section~132.\fi
\N144. Using the backpointers.
The routines in this section of the program are brought into play only
if \\{random\_reading} is \\{true}.
First comes a routine that illustrates how to find the postamble quickly.
\Y\P$\4\X144:Find the postamble, working back from the end\X\S$\6
$\|n\K\\{dvi\_length}$;\6
\&{if} $\|n<53$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'only\ \'},\39\|n:1,\39\.{\'\ bytes\ long\'})$;\2\6
$\|m\K\|n-4$;\6
\1\&{repeat} \37\&{if} $\|m=0$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'all\ 223s\'})$;\2\6
$\\{move\_to\_byte}(\|m)$;\5
$\|k\K\\{get\_byte}$;\5
$\\{decr}(\|m)$;\6
\4\&{until}\5
$\|k\I223$;\2\6
\&{if} $\|k\I\\{id\_byte}$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'ID\ byte\ is\ \'},\39\|k:1)$;\2\6
$\\{move\_to\_byte}(\|m-3)$;\5
$\|q\K\\{signed\_quad}$;\6
\&{if} $(\|q<0)\V(\|q>\|m-33)$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'post\ pointer\ \'},\39\|q:1,\39\.{\'\ at\ byte\ \'},\39%
\|m-3:1)$;\2\6
$\\{move\_to\_byte}(\|q)$;\5
$\|k\K\\{get\_byte}$;\6
\&{if} $\|k\I\\{post}$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'byte\ \'},\39\|q:1,\39\.{\'\ is\ not\ post\'})$;\2\6
$\\{post\_loc}\K\|q$;\5
$\\{first\_backpointer}\K\\{signed\_quad}$;\par
\U section~149\*.\fi
\M145. Note that the last steps of the above code save the locations of the
the \\{post} byte and the final \\{bop}. We had better declare these global
variables, together with others that we will need shortly.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4\\{post\_loc}: \37\\{integer};\C{byte location where the postamble begins}\6
\4\\{first\_backpointer}: \37\\{integer};\C{the pointer following \\{post}}\6
\4\\{new\_backpointer}: \37\\{integer};\C{the current \\{bop} command location}%
\par
\fi
\M146. The following routine locates the postamble in order to read the value
of the \\{first\_backpointer} but then processes the pages starting with the
last page so that the pages will be stacked properly by the \.{IMAGEN}.
\Y\P$\4\X146:Find the postamble then process the pages in reverse order\X\S$\6
$\|q\K\\{post\_loc}$;\5
$\\{move\_to\_byte}(\|q)$;\5
$\|k\K\\{get\_byte}$;\6
\&{if} $\|k\I\\{post}$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'byte\ \'},\39\|q:1,\39\.{\'\ is\ not\ post\'})$;\2\6
$\\{first\_backpointer}\K\\{signed\_quad}$;\5
$\\{new\_backpointer}\K\\{first\_backpointer}$;\6
\&{while} $\\{new\_backpointer}\I-1$ \1\&{do}\5
\\{next\_page};\2\6
\&{while} $\\{im\_byte\_no}\mathbin{\&{mod}}4\I3$ \1\&{do}\5
$\\{im\_byte}(\\{im\_no\_op})$;\2\6
$\\{im\_byte}(\\{im\_eof})$;\par
\U section~149\*.\fi
\N147. Reading the postamble.
Now imagine that we are reading the \.{DVI} file and positioned just
four bytes after the \\{post} command. That, in fact, is the situation,
when the following part of \.{DVIIMP} is called upon to read, translate,
and check the rest of the postamble.
\Y\P\4\&{procedure}\1\ \37\\{read\_postamble};\6
\4\&{var} \37\|k: \37\\{integer};\C{loop index}\6
$\|p,\39\|q,\39\|m$: \37\\{integer};\C{general purpose registers}\2\6
\&{begin} \37$\\{post\_loc}\K\\{cur\_loc}-5$;\6
\&{if} $\\{signed\_quad}\I\\{numerator}$ \1\&{then}\5
$\\{print\_ln}(\.{\'numerator\ doesn\'}\.{\'t\ match\ the\ preamble!\'})$;\2\6
\&{if} $\\{signed\_quad}\I\\{denominator}$ \1\&{then}\5
$\\{print\_ln}(\.{\'denominator\ doesn\'}\.{\'t\ match\ the\ preamble!\'})$;\2\6
\&{if} $\\{signed\_quad}\I\\{mag}$ \1\&{then}\6
\&{if} $\\{new\_mag}=0$ \1\&{then}\5
$\\{print\_ln}(\.{\'magnification\ doesn\'}\.{\'t\ match\ the\ preamble!\'})$;%
\2\2\6
$\\{max\_v}\K\\{signed\_quad}$;\5
$\\{max\_h}\K\\{signed\_quad}$;\6
$\\{max\_s}\K\\{get\_two\_bytes}$;\5
$\\{total\_pages}\K\\{get\_two\_bytes}$;\6
\X148:Process the font definitions of the postamble\X;\6
\&{end};\par
\fi
\M148. \P$\X148:Process the font definitions of the postamble\X\S$\6
\1\&{repeat} \37$\|k\K\\{get\_byte}$;\6
\&{if} $(\|k\G\\{fnt\_def1})\W(\|k<\\{fnt\_def1}+4)$ \1\&{then}\6
\&{begin} \37$\|p\K\\{first\_par}(\|k)$;\5
$\\{identify\_font}(\|p)$;\5
$\|k\K\\{nop}$;\6
\&{end};\2\6
\4\&{until}\5
$\|k\I\\{nop}$;\2\6
\&{if} $\|k\I\\{post\_post}$ \1\&{then}\5
$\\{print\_ln}(\.{\'byte\ \'},\39\\{cur\_loc}-1:1,\39\.{\'\ is\ not\ postpost!%
\'})$\2\par
\U section~147.\fi
\N149\*. The main program.
Now we are ready to put it all together. This is where \.{DVIIMP} starts,
and where it ends.
\Y\P\&{begin} \37\\{initialize};\C{get all variables initialized}\6
\X151:Process the preamble\X;\6
\\{open\_im\_file};\5
$\\{im\_byte}(\.{"@"})$;\5
$\\{im\_byte}(\.{"d"})$;\5
$\\{im\_byte}(\.{"o"})$;\5
$\\{im\_byte}(\.{"c"})$;\5
$\\{im\_byte}(\.{"u"})$;\5
$\\{im\_byte}(\.{"m"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"n"})$;\5
$\\{im\_byte}(\.{"t"})$;\5
$\\{im\_byte}(\.{"("})$;\5
$\\{im\_byte}(\.{"p"})$;\5
$\\{im\_byte}(\.{"a"})$;\5
$\\{im\_byte}(\.{"g"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"r"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"v"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"r"})$;\5
$\\{im\_byte}(\.{"s"})$;\5
$\\{im\_byte}(\.{"a"})$;\5
$\\{im\_byte}(\.{"l"})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{"o"})$;\5
$\\{im\_byte}(\.{"f"})$;\5
$\\{im\_byte}(\.{"f"})$;\5
$\\{im\_byte}(\.{","})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{"p"})$;\5
$\\{im\_byte}(\.{"a"})$;\5
$\\{im\_byte}(\.{"g"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"c"})$;\5
$\\{im\_byte}(\.{"o"})$;\5
$\\{im\_byte}(\.{"l"})$;\5
$\\{im\_byte}(\.{"l"})$;\5
$\\{im\_byte}(\.{"a"})$;\5
$\\{im\_byte}(\.{"t"})$;\5
$\\{im\_byte}(\.{"i"})$;\5
$\\{im\_byte}(\.{"o"})$;\5
$\\{im\_byte}(\.{"n"})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{"o"})$;\5
$\\{im\_byte}(\.{"f"})$;\5
$\\{im\_byte}(\.{"f"})$;\5
$\\{im\_byte}(\.{","})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{"l"})$;\5
$\\{im\_byte}(\.{"a"})$;\5
$\\{im\_byte}(\.{"n"})$;\5
$\\{im\_byte}(\.{"g"})$;\5
$\\{im\_byte}(\.{"u"})$;\5
$\\{im\_byte}(\.{"a"})$;\5
$\\{im\_byte}(\.{"g"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{"i"})$;\5
$\\{im\_byte}(\.{"m"})$;\5
$\\{im\_byte}(\.{"P"})$;\5
$\\{im\_byte}(\.{"r"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"s"})$;\5
$\\{im\_byte}(\.{"s"})$;\5
$\\{im\_byte}(\.{","})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{"O"})$;\5
$\\{im\_byte}(\.{"w"})$;\5
$\\{im\_byte}(\.{"n"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"r"})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{""}\.{""})$;\5
$\\{calli}(\O{24},\390,\390,\39\\{ppn}.\\{int},\39\\{success})$;\6
\&{for} $\\{dvi\_n\_len}\K1\mathrel{\&{to}}6$ \1\&{do}\5
$\\{im\_byte}(\\{ppn}.\\{sixbit}[\\{dvi\_n\_len}]+\O{40})$;\2\6
$\\{im\_byte}(\.{""}\.{""})$;\5
$\\{im\_byte}(\.{","})$;\5
$\\{im\_byte}(\.{"N"})$;\5
$\\{im\_byte}(\.{"a"})$;\5
$\\{im\_byte}(\.{"m"})$;\5
$\\{im\_byte}(\.{"e"})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{""}\.{""})$;\5
$\\{cur\_nam}(\\{dvi\_file},\39\\{dvi\_name})$;\5
$\\{dvi\_n\_len}\K1$;\6
\&{while} $\\{ord}(\\{dvi\_name}[\\{dvi\_n\_len}])\I0$ \1\&{do}\6
\&{begin} \37$\\{im\_byte}(\\{xord}[\\{dvi\_name}[\\{dvi\_n\_len}]])$;\5
$\\{incr}(\\{dvi\_n\_len})$;\6
\&{end};\2\6
$\\{im\_byte}(\.{""}\.{""})$;\5
$\\{im\_byte}(\.{","})$;\5
$\\{im\_byte}(\.{"D"})$;\5
$\\{im\_byte}(\.{"V"})$;\5
$\\{im\_byte}(\.{"I"})$;\5
$\\{im\_byte}(\.{"-"})$;\5
$\\{im\_byte}(\.{"i"})$;\5
$\\{im\_byte}(\.{"d"})$;\5
$\\{im\_byte}(\.{"\ "})$;\5
$\\{im\_byte}(\.{""}\.{""})$;\6
\&{for} $\|p\K0\mathrel{\&{to}}\\{id\_len}$ \1\&{do}\5
$\\{im\_byte}(\\{id}[\|p])$;\2\6
$\\{im\_byte}(\.{""}\.{""})$;\5
$\\{im\_byte}(\.{")"})$;\5
\X144:Find the postamble, working back from the end\X;\6
\\{read\_postamble};\5
\X146:Find the postamble then process the pages in reverse order\X;\6
\4\\{final\_end}: \37$\\{close}(\\{im\_file})$;\5
$\\{close}(\\{dvi\_file})$;\5
$\\{esp}(\\{dvi\_file},\39\\{im\_file})$;\6
\&{end}.\par
\fi
\M150. The main program needs a few global variables in order to do its work.
\Y\P$\4\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4$\|k,\39\|m,\39\|n,\39\|p,\39\|q$: \37\\{integer};\C{general purpose
registers}\6
\4\\{id\_len}: \37$0\to255$;\6
\4\\{id}: \37\&{packed} \37\&{array} $[0\to255]$ \1\&{of}\5
$0\to255$;\2\par
\fi
\M151. A \.{DVI}-reading program that reads the postamble first need not look
at the
preamble; but \.{DVIIMP} looks at the preamble in order to do error
checking, and to display the introductory comment.
\Y\P$\4\X151:Process the preamble\X\S$\6
\\{open\_dvi\_file};\5
$\|p\K\\{get\_byte}$;\C{fetch the first byte}\6
\&{if} $\|p\I\\{pre}$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'First\ byte\ isn\'}\.{\'t\ start\ of\ preamble!\'})$;\2\6
$\|p\K\\{get\_byte}$;\C{fetch the identification byte}\6
\&{if} $\|p\I\\{id\_byte}$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'identification\ in\ byte\ 1\ should\ be\ \'},\39\\{id%
\_byte}:1,\39\.{\'!\'})$;\2\6
\X152:Compute the conversion factor\X;\6
$\\{id\_len}\K\\{get\_byte}$;\C{fetch the length of the introductory comment}\6
$\|p\K0$;\6
\&{while} $\|p<\\{id\_len}$ \1\&{do}\6
\&{begin} \37$\\{incr}(\|p)$;\5
$\\{id}[\|p]\K\\{get\_byte}$;\6
\&{end};\2\par
\U section~149\*.\fi
\M152. The conversion factor \\{conv} is figured as follows: There are exactly
$\|n/\|d$ \.{DVI} units per decimicron, and 254000 decimicrons per inch,
and \\{resolution} pixels per inch. Then we have to adjust this
by the stated amount of magnification.
\Y\P$\4\X152:Compute the conversion factor\X\S$\6
$\\{numerator}\K\\{signed\_quad}$;\5
$\\{denominator}\K\\{signed\_quad}$;\6
\&{if} $\\{numerator}\L0$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'numerator\ is\ \'},\39\\{numerator}:1)$;\2\6
\&{if} $\\{denominator}\L0$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'denominator\ is\ \'},\39\\{denominator}:1)$;\2\6
$\\{conv}\K(\\{numerator}/254000.0)\ast(\\{resolution}/\\{denominator})$;\5
$\\{mag}\K\\{signed\_quad}$;\6
\&{if} $\\{new\_mag}>0$ \1\&{then}\5
$\\{mag}\K\\{new\_mag}$\6
\4\&{else} \&{if} $\\{mag}\L0$ \1\&{then}\5
$\\{bad\_dvi}(\.{\'magnification\ is\ \'},\39\\{mag}:1)$;\2\2\6
$\\{true\_conv}\K\\{conv}$;\5
$\\{conv}\K\\{true\_conv}\ast(\\{mag}/1000.0)$;\par
\U section~151.\fi
\N153\*. System-dependent changes.
This section should be replaced, if necessary, by changes to the program
that are necessary to make \.{DVIIMP} work at a particular installation.
It is usually best to design your change file so that all changes to
previous sections preserve the section numbering; then everybody's version
will be consistent with the printed program. More extensive changes,
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
\Y\P$\4\X5:Constants in the outer block\X\mathrel{+}\S$\6
$\\{f\_name\_size}=24$;\par
\fi
\M154\*. \P$\X8:Types in the outer block\X\mathrel{+}\S$\6
$\\{file\_name}=$\1\5
\&{packed} \37\&{array} $[1\to\\{f\_name\_size}]$ \1\&{of}\5
\\{char};\2\2\par
\fi
\M155\*. \P$\X10:Globals in the outer block\X\mathrel{+}\S$\6
\4$\\{imp\_name},\39\\{dvi\_name}$: \37\\{file\_name};\6
\4\\{dvi\_n\_len}: \37$1\to\\{f\_name\_size}$;\C{file names at {\sc SAIL} have
at most 23 characters}\6
\4\\{ppn}: \37\&{record} \&{case} $\\{integer}$ \1\&{of}\6
\41: \37$(\\{int}:\\{integer})$;\6
\42: \37$($$\\{sixbit}:$\1\5
\&{packed} \37\&{array} $[1\to6]$ \1\&{of}\5
$0\to\O{77}$\2\2$)$\2\6
\&{end};\6
\4\\{success}: \37\\{boolean};\par
\fi
\N156\*. Index.
Pointers to error messages appear here together with the section numbers
where each ident\-i\-fier is used.
\fi
\ch 3\*, 28\*, 29\*, 81\*, 100\*, 102\*, 103\*, 149\*, 153\*, 154\*, 155\*, 156%
\*.
\inx
\:\|{a}, \[31], \[34], \[104], \[113], \[128], \[132].
\:\\{abort}, \[7], 54, 95, 96, 102\*, 103\*.
\:\\{abs}, 94, 122, 129, 135, 141, 142.
\:\\{advance\_q}, \[111], 115, 117, 118, 119.
\:\.{all 223s}, 144.
\:\\{alpha}, \[58], 62, 63, \[64], 67.
\:\.{arithmetic overflow...}, 141, 142.
\:\\{ASCII\_code}, \[8], 10, 45, 46, 81\*.
\:\\{atab}, \[111], 112, 114.
\:\|{b}, \[31], \[34], \[115].
\:{backpointers}, 43.
\:\.{bad design size}, 97.
\:\.{Bad DVI file}, 7.
\:\.{bad scale}, 97.
\:\\{bad\_char}, \[132], 137.
\:\\{bad\_dvi}, \[7], 130, 132, 133, 137, 143, 144, 146, 151, 152.
\:\\{banner}, \[1], 3\*, 86.
\:\\{bc}, \[46], 52, 54, 55, 59, 62.
\:\&{begin}, 1.
\:\\{beta}, \[58], 62, 63, \[64], 67.
\:\\{bgly}, 51, 74.
\:\\{bitmap}, \[22].
\:\\{black}, 39, 40.
\:\\{boc}, 38, 40, \[41], 42, 43, 52, 69, 70, 74, 106.
\:\\{boc1}, 38, 40, \[41], 52, 69, 72, 74, 106.
\:\\{boolean}, 28\*, 51, 58, 61, 64, 78, 80, 85, 95, 99, 132, 155\*.
\:\\{bop}, 13, 15, \[16], 18, 19, 77, 120, 124, 129, 133, 145.
\:\.{bop occurred before eop}, 133.
\:\\{break}, 82.
\:\\{btab}, \[111], 112, 116.
\:\\{buf\_ptr}, \[84], 85, 87, 88, 89, 90.
\:\\{buffer}, \[81\*], 83, 84, 85, 87, 88, 89, 90.
\:\.{byte n is not post}, 144, 146.
\:\.{byte n is not postpost}, 148.
\:\\{byte\_file}, \[23], 24.
\:\\{bytes\_required}, 115, 116, 117, 118, 119.
\:\\{b0}, \[32], 33, 65, 66, 67.
\:\\{b1}, \[32], 33, 65, 67.
\:\\{b2}, \[32], 33, 65, 67.
\:\\{b3}, \[32], 33, 65, 67.
\:\|{c}, \[31], \[34], \[52], \[58], \[95], \[99], \[104], \[115].
\:\\{calli}, 149\*.
\:\\{chan}, \[28\*].
\:\\{change\_font}, \[126], 132, 136.
\:\\{char}, 9, 30, 100\*, 154\*.
\:\\{char\_code}, \[55], 71, 73, 107, 108.
\:\\{char\_loc}, 40, \[41], 43, 52, 54, 61.
\:\\{char\_loc0}, \[40].
\:\\{char\_pixel\_width}, \[61], 139.
\:\\{char\_width}, \[46], 61, 139.
\:\\{char\_width\_end}, \[46], 61.
\:\.{character $c$ invalid...}, 139.
\:{check sum}, 18, 42.
\:\\{check\_sum}, 52, \[55].
\:{Chinese characters}, 15, 43, 139.
\:\\{chr}, 9, 10, 12, 29\*.
\:\\{circ\_arc}, \[22].
\:\\{circ\_segm}, \[22].
\:\\{close}, 149\*.
\:\\{column\_count}, \[55], 76.
\:\\{conv}, \[61], 125, 128, 152.
\:\\{copies}, \[25], 26, 27.
\:\\{copy\_byte}, \[52].
\:\\{count}, 25, \[78], 80, 129.
\:\\{create\_family\_table}, 21, \[22].
\:\\{create\_map}, 21, \[22].
\:\\{create\_path}, \[22].
\:\\{cs}, \[42].
\:\\{cur\_font}, 45, 59, 62, 65, 68, 69, 71, 73, 99, 102\*, 103\*, 104, 106,
115, 126, \[127], 128, 134, 135, 139, 143.
\:\\{cur\_gf\_loc}, 28\*, \[30], 31, 36, 51, 52, 69, 106, 110.
\:\\{cur\_loc}, 28\*, \[30], 34, 35, 130, 147, 148.
\:\\{cur\_nam}, \[28\*], 29\*, 149\*.
\:\\{cur\_name}, 28\*, \[30], 95, 99, 102\*.
\:\\{cur\_pos}, 35, 36.
\:\\{cur\_tfm\_name}, 28\*, \[30], 103\*.
\:\|{d}, \[31], \[34], \[95], \[99].
\:\\{data\_base}, \[46], 55, 61, 62, 68, 69, 106, 115, 139.
\:\\{data\_start}, 45, \[55], 62.
\:\&{debug}, \[1], \[45], \[51], \[54], \[57], \[58], \[59], \[62], \[69], %
\[71], \[73], \[93], \[96], \[99], \[106], \[107], \[115], \[129], \[138], %
\[139].
\:\\{decr}, \[6], 51, 60, 71, 73, 75, 76, 96, 105, 110, 118, 133, 144.
\:\.{deeper than claimed...}, 133.
\:\\{default\_directory}, \[100\*], 101, 102\*.
\:\\{default\_directory\_name}, \[100\*], 101.
\:\\{default\_directory\_name\_length}, \[100\*], 102\*.
\:\\{define\_macro}, \[22].
\:\\{del\_m}, \[40], \[58], 73, \[104], 107, 108, 109.
\:\\{del\_n}, \[40], \[58], 73, \[104], 107, 108, 109.
\:\\{den}, 15, \[17], 19.
\:\\{denominator}, \[61], 147, 152.
\:\.{denominator doesn't match}, 147.
\:\.{denominator is wrong}, 152.
\:{design size}, 42.
\:\\{design\_size}, 52, \[55].
\:\\{dflt\_tfm\_directory}, \[100\*], 101, 103\*.
\:\\{dflt\_tfm\_directory\_name}, \[100\*], 101.
\:\\{dflt\_tfm\_directory\_name\_length}, \[100\*], 103\*.
\:\\{dialog}, 77, \[86].
\:\\{dis}, 115, 116, 117, 118.
\:\\{dm}, \[40].
\:\\{do\_char}, 6.
\:\\{do\_im\_bgly}, \[115], 139.
\:\\{do\_nothing}, \[6].
\:\\{do\_page}, 6, 120, 124, 126, 127, \[128], 129, 131.
\:\\{done}, \[4], 29\*, 58, 76, 94, 104, 128, 130, 131, 132, 133, 136, 137,
139, 140, 141, 142, 143.
\:\\{down1}, 15, \[16], 124, 135.
\:\\{down2}, 15.
\:\\{down3}, 15.
\:\\{down4}, 15.
\:\\{draw\_path}, \[22].
\:\\{ds}, \[42].
\:\\{dvi}, 25.
\:\.{DVI {\rm files}}, 13.
\:\\{dvi\_file}, 3\*, \[24], \[28\*], 29\*, 30, 34, 35, 130, 149\*.
\:\\{DVI\_IMP}, \[3\*].
\:\\{dvi\_length}, \[35], 144.
\:\\{dvi\_n\_len}, 149\*, \[155\*].
\:\\{dvi\_name}, 28\*, 149\*, \[155\*].
\:\.{DVIIMP capacity exceeded...}, 95, 96.
\:\.{DVItype capacity exceeded...}, 102\*, 103\*.
\:\.{DVItype needs larger...}, 65.
\:\\{dx}, 40, 43, 54, \[55], 61, 62.
\:\\{dy}, 40, 43, 54, \[55].
\:\|{e}, \[95].
\:\\{ec}, 46, 52, 54, 59, 62.
\:\\{eight\_bits}, \[23], 31, 32, 34, 46, 52, 55, 113, 124, 128, 132.
\:\\{eight\_cases}, \[6].
\:\\{eighty\_three\_cases}, \[6].
\:\\{ellipse\_arc}, \[22].
\:\&{else}, 2.
\:\\{empty\_glyph}, \[61], 69, 71, 73.
\:\&{end}, 1, 2.
\:\&{endcases}, \[2].
\:\\{eoc}, 38, 40, \[41], 42, 52, 76, 110, 115.
\:\\{eof}, 28\*, 31, 34, 35, 52, 65, 99, 130.
\:\\{eoln}, 28\*, 83.
\:\\{eop}, 13, 15, \[16], 18, 21, 77, 124, 133.
\:\\{errors\_only}, 77.
\:\\{erstat}, \[28\*], 29\*.
\:\\{esp}, \[28\*], 149\*.
\:\\{execute\_macro}, \[22].
\:\\{extern}, 28\*.
\:\|{f}, \[28\*], \[48], \[49], \[95].
\:\\{f\_name\_size}, 28\*, \[153\*], 154\*, 155\*.
\:\\{false}, 2, 20, 28\*, 51, 58, 64, 69, 71, 73, 78, 79, 80, 85, 87, 137.
\:\\{family}, 21.
\:\\{file\_name}, \[154\*], 155\*.
\:\\{fill\_path}, \[22].
\:\\{fin\_rule}, \[126], 128, 130, 131.
\:\\{fin\_set}, \[126], 128, 130, 131.
\:\\{final\_end}, \[4], 7, 149\*.
\:\\{find\_gf\_postamble}, \[51], 58.
\:\.{First byte isn't...}, 151.
\:\\{first\_backpointer}, 129, 144, \[145], 146.
\:\\{first\_gf\_par}, 51, \[52], 75.
\:\\{first\_par}, 51, \[124], 130, 131, 148.
\:\\{first\_text\_char}, \[9], 12.
\:\\{fix\_word}, 61.
\:\\{fnt\_def1}, 15, \[16], 92, 98, 124, 136, 148.
\:\\{fnt\_def2}, 15.
\:\\{fnt\_def3}, 15.
\:\\{fnt\_def4}, 15.
\:\\{fnt\_num}, 92.
\:\\{fnt\_num\_0}, 15, \[16], 124, 136.
\:\\{fnt\_num\_1}, 15.
\:\\{fnt\_num\_63}, 15.
\:\\{fnt1}, 15, \[16], 124, 136.
\:\\{fnt2}, 15.
\:\\{fnt3}, 15.
\:\\{fnt4}, 15.
\:\\{font\_a\_val}, \[92], 96, 99.
\:\\{font\_bc}, \[46], 59, 65, 68, 139.
\:\\{font\_check\_sum}, \[46], 96.
\:\\{font\_design\_size}, \[46], 96.
\:\\{font\_ec}, \[46], 59, 65, 139.
\:\\{font\_l\_val}, \[92], 96, 99.
\:\\{font\_m\_val}, \[46], 49, 96, 99, 102\*.
\:\\{font\_name}, 45, \[46], 47, 48, 96, 102\*, 103\*.
\:\\{font\_num}, 45, \[46], 95, 143.
\:\\{font\_order}, 45, \[55], 56, 69, 106.
\:\\{font\_scaled\_size}, \[46], 96, 143.
\:\\{font\_space}, \[46], 47, 95, 134, 135.
\:\\{font\_state}, \[92], 95, 99, 104, 139, 143.
\:\\{four\_cases}, \[6], 131, 132, 134, 135, 136.
\:\\{free\_limit}, 45, 46, \[55], 56, 69.
\:{Fuchs, David Raymond}, 13, 20, 44.
\:\|{g}, \[128].
\:\\{get}, 27, 28\*, 83.
\:\\{get\_byte}, \[34], 35, 96, 98, 124, 129, 130, 137, 144, 146, 148, 151.
\:\\{get\_gf\_file}, \[99], 104, 143.
\:\\{get\_integer}, \[85], 87, 88, 89, 90.
\:\\{get\_three\_bytes}, \[34], 124.
\:\\{get\_two\_bytes}, \[34], 124, 147.
\:\\{gf}, 45, 51, 58, 70, 104.
\:\.{GF {\rm files}}, 45.
\:\.{GF file is bad}, 58.
\:\\{gf\_byte}, \[31], 36, 51, 52, 54, 60, 73, 75, 76, 105, 108, 110.
\:\\{gf\_check\_sum}, \[50].
\:\\{gf\_file}, \[24], 28\*, 30, 31, 36, 50, 52, 99.
\:\\{gf\_id\_byte}, \[40], 51, 60.
\:\\{gf\_length}, \[36], 51.
\:\\{gf\_post\_loc}, 51, 52, \[55].
\:\\{gf\_postamble}, 52.
\:\.{gf\_postamble starts at byte n}, 52.
\:\\{gf\_prev\_ptr}, \[55], 69, 106.
\:\\{gf\_ptr}, \[46], 53, 54, 62.
\:\\{gf\_signed\_quad}, \[31], 51, 52, 54, 71, 107.
\:\\{gf\_three\_bytes}, \[31], 52.
\:\\{gf\_two\_bytes}, \[31], 52.
\:\\{glyph\_ptr}, 43, 45, 46, 51, \[55], 56, 57, 58, 68, 69, 92, 106, 115, 128,
139.
\:\&{gubed}, \[1].
\:\|{h}, \[121].
\:\\{height}, 21.
\:\\{hh}, \[121], 128, 133, 134, 138, 139, 140, 141.
\:\\{hhh}, \[128], 141.
\:\\{hhi}, \[121], 128, 138, 139, 141.
\:\\{hhstack}, \[121], 133.
\:\\{hppp}, \[42], 52, \[55].
\:\\{hstack}, \[121], 133.
\:\|{i}, \[3\*], \[17], \[28\*], \[29\*], \[45], \[57], \[94], \[98], \[114].
\:\\{id}, 149\*, \[150], 151.
\:\.{ID byte is wrong}, 144.
\:\\{id\_byte}, \[17], 144, 151.
\:\\{id\_len}, 149\*, \[150], 151.
\:\.{identification...should be n}, 151.
\:\\{identify\_font}, \[95], 148.
\:\\{im\_bgly}, 21, \[22], 111, 115.
\:\\{im\_brule}, 21, \[22], 140.
\:\\{im\_byte}, \[37], 115, 116, 118, 128, 138, 139, 140, 141, 142, 143, 146,
149\*.
\:\\{im\_byte\_no}, 29\*, \[30], 37, 146.
\:\\{im\_crlf}, 21, \[22].
\:\\{im\_end\_page}, 21, \[22], 128.
\:\\{im\_eof}, 21, \[22], 146.
\:\\{im\_extension}, 45, \[46], 47, 71, 73, 115, 139.
\:\\{im\_file}, \[24], 28\*, 29\*, 30, 37, 149\*.
\:\\{im\_halfword}, \[37], 115, 138, 140, 141, 142.
\:\\{im\_member}, 21.
\:\\{im\_mminus}, 21, \[22].
\:\\{im\_mmove}, 21, \[22].
\:\\{im\_mplus}, 21, \[22].
\:\\{im\_no\_op}, 21, \[22], 146.
\:\\{im\_page}, 21, \[22].
\:\\{im\_pop}, 21, \[22].
\:\\{im\_push}, 21, \[22].
\:\\{im\_sbyte}, \[37].
\:\\{im\_set\_adv\_dirs}, 21, \[22].
\:\\{im\_set\_bol}, 21, \[22].
\:\\{im\_set\_il}, 21, \[22].
\:\\{im\_set\_rel\_h}, 21.
\:\\{im\_set\_rel\_v}, 21.
\:\\{im\_set\_sp}, 21, \[22].
\:\\{im\_smove}, 21, \[22].
\:\\{im\_sp}, 21, \[22].
\:\\{im\_sp1}, 21, \[22].
\:\\{imp\_name}, 29\*, \[155\*].
\:\\{in\_gf}, \[58], 61, 143.
\:\\{in\_tfm}, \[64], 143.
\:\\{in\_width}, \[46], 67, 68.
\:\\{incr}, \[6], 28\*, 29\*, 31, 34, 37, 46, 62, 69, 71, 73, 76, 83, 85, 87,
89, 95, 96, 102\*, 103\*, 106, 111, 113, 116, 133, 143, 149\*, 151.
\:\\{infinity}, \[128], 141, 142.
\:\\{initialize}, \[3\*], 149\*.
\:\\{input\_ln}, 81\*, \[83], 87, 88, 89, 90.
\:\\{int}, 149\*, \[155\*].
\:\\{integer}, 3\*, 23, 25, 28\*, 29\*, 30, 31, 34, 35, 36, 37, 45, 46, 48, 49,
50, 51, 52, 55, 57, 58, 61, 64, 77, 78, 85, 86, 92, 94, 95, 98, 99, 104, 111,
113, 114, 115, 121, 122, 124, 125, 127, 128, 129, 132, 145, 147, 150, 155\*.
\:\\{invalid\_width}, \[46], 62, 68, 139.
\:\|{j}, \[95], \[99].
\:{Japanese characters}, 15, 43, 139.
\:\\{jj}, 3\*, 93.
\:\\{jump\_out}, \[7].
\:\|{k}, \[17], \[48], \[51], \[52], \[58], \[64], \[80], \[83], \[86], \[95], %
\[99], \[104], \[129], \[132], \[147], \[150].
\:\\{last\_page}, \[25], 26, 27, 129.
\:\\{last\_text\_char}, \[9], 12.
\:\\{lh}, \[58], \[64], 65.
\:\\{line\_length}, \[5].
\:\|{m}, \[49], \[52], \[95], \[99], \[147], \[150].
\:\\{mag}, 15, \[17], 18, 19, \[61], 95, 96, 99, 147, 152.
\:\\{magnification}, 52, \[55].
\:\.{magnification doesn't match}, 147.
\:\.{magnification is wrong}, 152.
\:\\{make\_space}, \[45], 46.
\:\\{match}, \[80].
\:\\{max\_char\_no}, \[5], 46, 52, 53, 54, 55.
\:\\{max\_column\_count}, \[55], 76.
\:\\{max\_drift}, \[141], 142.
\:\\{max\_fonts}, \[5], 45, 46, 47, 55, 56, 92, 95.
\:\\{max\_glyphs}, \[5], 46, 55, 56, 58, 59, 61, 64, 65.
\:\\{max\_h}, \[122], 147.
\:\\{max\_m}, 40, 42, 52, \[55], 71, 73, 107, 108.
\:\\{max\_n}, 40, 42, 52, \[55], 71, 73, 107, 108, 109.
\:\\{max\_pages}, 26, \[77], 79, 88, 91.
\:\\{max\_s}, \[122], 123, 133, 147.
\:\\{max\_s\_so\_far}, \[122], 123, 133.
\:\\{max\_v}, \[122], 147.
\:\\{min\_m}, 40, 42, 52, \[55], 71, 107, 108, 109.
\:\\{min\_n}, 40, 42, 52, \[55], 71, 107.
\:\\{mismatch}, \[95], \[99].
\:\\{mm}, 46, \[55], 56, 106.
\:\\{mm\_max}, \[5], 45, 56.
\:\\{mm\_save}, \[58], 69, \[104], 106.
\:\\{mm\_size}, \[5], 45.
\:\\{mm\_store}, 1, 5, 43, 45, 46, 51, \[55], 70, 72, 76, 92, 111, 113, 115,
117, 118, 119.
\:\\{mm\_tmp}, 113.
\:\\{move\_down}, \[126], 132, 135.
\:\\{move\_right}, \[126], 128, 130, 134, 139, 140.
\:\\{move\_to\_byte}, \[35], 129, 144, 146.
\:\\{move\_to\_gf\_byte}, \[36], 51.
\:\\{m1}, 46, \[55], 56, 69, 106.
\:\\{m1\_max}, \[5], 46, 55, 76, 111, 113.
\:\\{m1\_save}, \[58], 69, 76, \[104], 106.
\:\\{m1\_tmp}, 113.
\:\\{m2}, 46, \[55], 56, 69, 106, 111.
\:\\{m2\_max}, \[5], 46, 55, 76, 111, 113.
\:\\{m2\_save}, \[58], 69, 76, \[104], 106.
\:\\{m2\_size}, \[5], 57, 69, 106, 113, 115.
\:\\{m2\_tmp}, 113.
\:\|{n}, \[95], \[99], \[125], \[150].
\:\\{name\_length}, \[5], 30, 95, 99, 102\*, 103\*.
\:\\{name\_size}, \[5], 46, 48, 95, 96, 99.
\:\\{names}, 45, \[46], 48, 95, 96, 99, 102\*, 103\*.
\:\\{negative}, \[85].
\:\\{new\_backpointer}, 129, \[145], 146.
\:\\{new\_mag}, \[77], 79, 90, 91, 147, 152.
\:\\{new\_row\_0}, 40, \[41], 52, 76, 110, 115, 117.
\:\\{new\_row\_1}, \[40].
\:\\{new\_row\_164}, \[40], \[41], 110, 115.
\:\\{next\_page}, \[129], 146.
\:\\{nf}, 45, \[46], 47, 48, 71, 73, 95, 96, 128, 139, 143.
\:\\{nf2}, \[46], 47, 71, 73.
\:\\{nine\_cases}, \[6].
\:\\{nineteen\_cases}, \[6].
\:\\{no\_op}, 40, \[41], 43, 52, 54, 75, 76.
\:\.{non-ASCII character...}, 137.
\:\\{nop}, 13, 15, \[16], 18, 19, 21, 124, 133, 148.
\:\.{null n+p}, 96.
\:\\{num}, 15, \[17], 19.
\:\\{num\_pages}, \[25], 27.
\:\\{numerator}, \[61], 147, 152.
\:\.{numerator doesn't match}, 147.
\:\.{numerator is wrong}, 152.
\:\\{nw}, \[58], 59, \[64], 65, 66, 67.
\:\|{o}, \[58], \[104], \[128], \[132].
\:\\{one\_sixty\_five\_cases}, \[6], 52, 76.
\:\.{only n bytes long}, 144.
\:\\{open\_dvi\_file}, \[28\*], 151.
\:\\{open\_gf\_file}, \[28\*], 30, 60, 99.
\:\\{open\_im\_file}, \[29\*], 149\*.
\:\\{open\_tfm\_file}, \[28\*], 99.
\:\.{Options selected}, 91.
\:\\{ord}, 10, 29\*, 149\*.
\:{oriental characters}, 15, 43, 139.
\:\&{othercases}, \[2].
\:\\{others}, 2.
\:\\{out\_mode}, 77.
\:\\{out\_space}, 95, \[134].
\:\\{out\_vmove}, 95, \[135].
\:\\{output}, 3\*.
\:\|{p}, \[52], \[58], \[95], \[99], \[104], \[128], \[129], \[132], \[147], %
\[150].
\:\\{paint}, 39.
\:\\{paint\_switch}, \[39], 40.
\:\\{paint\_0}, 40, \[41], 52, 76.
\:\\{paint1}, 40, \[41], 52, 76, 110, 117, 119.
\:\\{paint2}, \[40], \[41], 52, 76, 110, 117, 119.
\:\\{paint3}, \[40].
\:\\{pixel\_round}, \[61], 68, 121, 128, 134, 135, 141, 142.
\:\\{pixel\_width}, 46, \[61], 62, 68, 92, 115, 139.
\:\\{pop}, 14, 15, \[16], 19, 124, 133.
\:\\{post}, 13, 15, \[16], 19, 20, 38, 40, 42, 44, 51, 52, 69, 106, 124, 132,
144, 145, 146, 147.
\:\.{post pointer is wrong}, 144.
\:\\{post\_loc}, 144, \[145], 146, 147.
\:\\{post\_post}, 15, \[16], 19, 20, 40, 41, 42, 44, 52, 124, 132, 148.
\:\.{postamble command within a page}, 132.
\:\\{ppn}, 149\*, \[155\*].
\:\\{pre}, 13, 15, \[16], 38, 40, 52, 60, 124, 132, 151.
\:\.{preamble command within a page}, 132.
\:\\{print}, \[3\*], 7, 45, 48, 49, 54, 57, 62, 69, 71, 73, 91, 96, 97, 99,
106, 107, 114, 115, 129, 137, 138, 139, 141, 142.
\:\\{print\_extension}, \[49], 99.
\:\\{print\_font}, \[48], 96, 99, 139.
\:\\{print\_ln}, \[3\*], 45, 51, 54, 57, 58, 59, 60, 62, 64, 65, 69, 71, 73,
76, 91, 93, 96, 99, 115, 129, 139, 147, 148.
\:\\{proofing}, 43.
\:\\{push}, 5, 14, 15, \[16], 19, 124, 133.
\:\.{push deeper than claimed...}, 133.
\:\\{put\_rule}, 15, \[16], 124, 131, 140.
\:\\{put1}, 15, \[16], 124, 131, 139.
\:\\{put2}, 15.
\:\\{put3}, 15.
\:\\{put4}, 15.
\:\|{q}, \[51], \[52], \[95], \[99], \[128], \[132], \[147], \[150].
\:\\{q1}, 111, 115, 117, 118, 119.
\:\\{q2}, 111, 115, 117, 118, 119.
\:\|{r}, \[95], \[99].
\:\\{random\_reading}, \[2], 20, 35, 144.
\:\\{read}, 31, 33, 34.
\:\\{read\_c}, \[27].
\:\\{read\_f}, \[27].
\:\\{read\_gf\_postamble}, 51, \[52], 58.
\:\\{read\_ln}, 28\*, 83.
\:\\{read\_n}, \[27].
\:\\{read\_postamble}, \[147], 149\*.
\:\\{read\_signed\_pair}, \[113], 115.
\:\\{read\_tfm\_word}, \[33], 65, 66, 67.
\:\\{real}, 3\*, 55, 61, 77.
\:\\{real\_w}, 115.
\:\\{reconcile\_scale}, \[94], 96.
\:\\{reload\_font}, \[104], 139.
\:\\{rescan}, \[28\*].
\:\\{reset}, 28\*, 29\*, 83.
\:\\{resolution}, 52, \[77], 79, 89, 91, 93, 96, 152.
\:\\{restart}, \[4], 58, 76, 104.
\:\\{rewrite}, 29\*, 86.
\:\\{right1}, 15, \[16], 124, 134.
\:\\{right2}, 15.
\:\\{right3}, 15.
\:\\{right4}, 15.
\:\\{round}, 61, 93, 96, 128.
\:\\{row\_count}, \[55], 76.
\:\\{rule\_pixels}, 15, \[125], 140.
\:\|{s}, \[28\*], \[127].
\:\\{scale\_val}, \[92], 93, 94.
\:\\{scaled}, 40, 42, 43.
\:\\{seen\_dot}, \[28\*].
\:\\{seen\_left\_bracket}, \[28\*].
\:\\{seen\_right\_bracket}, \[28\*].
\:\\{set\_abs\_h}, 21, \[22], 138, 141.
\:\\{set\_abs\_v}, 21, \[22], 138, 142.
\:\\{set\_char\_0}, 15, \[16], 21, 124, 131.
\:\\{set\_char\_1}, 15.
\:\\{set\_char\_127}, 15.
\:\\{set\_family}, 21, \[22], 139, 143.
\:\\{set\_hv\_system}, 21, \[22].
\:\\{set\_magnification}, \[22].
\:\\{set\_pen}, \[22].
\:\\{set\_pos}, 35, 36.
\:\\{set\_pum}, \[22].
\:\\{set\_push\_mask}, 21, \[22].
\:\\{set\_rel\_h}, 21, \[22].
\:\\{set\_rel\_v}, 21, \[22].
\:\\{set\_rule}, 13, 15, \[16], 124, 131.
\:\\{set\_texture}, \[22].
\:\\{set1}, 15, \[16], 124, 131.
\:\\{set2}, 15.
\:\\{set3}, 15.
\:\\{set4}, 15.
\:\\{show\_it}, \[114].
\:\\{signed\_byte}, \[34], 124.
\:\\{signed\_pair}, \[34], 124.
\:\\{signed\_pairs}, 70, 72.
\:\\{signed\_quad}, \[34], 70, 96, 124, 129, 140, 144, 146, 147, 152.
\:\\{signed\_trio}, \[34], 124.
\:\\{sixbit}, 149\*, \[155\*].
\:\\{sixteen\_cases}, \[6].
\:\\{sixty\_four\_cases}, \[6], 52, 76, 124, 136.
\:\\{skip\_it}, \[98], 136.
\:\\{skip0}, 40, \[41], 52, 76, 110, 115, 118.
\:\\{skip1}, 40, \[41], 52, 76, 110.
\:\\{skip2}, \[40], \[41], 52, 110.
\:\\{skip3}, \[40].
\:{sp}, 17.
\:\\{special\_cases}, 127, 131, \[132].
\:\.{stack not empty...}, 133.
\:\\{stack\_size}, \[5], 121, 123, 133.
\:\\{start\_count}, \[78], 80, 87, 91.
\:\\{start\_match}, \[80].
\:\\{start\_page}, \[25], 26, 27, 129.
\:\\{start\_there}, \[78], 79, 80, 87, 91.
\:\\{start\_vals}, \[78], 79, 80, 87, 91.
\:\\{stow}, \[46], 52, 76.
\:\\{stow\_pair}, \[52].
\:\\{stow\_signed\_pair}, \[52], 71, 73, 109.
\:\\{string}, 28\*.
\:\.{string of negative length}, 137.
\:\\{success}, 149\*, \[155\*].
\:{system dependencies}, \[2], 7, 9, 20, 23, 28\*, 31, 33, 34, 35, 36, 44, 49,
77, 81\*, 82, 83, 86, 94, 100\*, 102\*, 153\*.
\:\\{tabulate}, \[57], 58.
\:\\{tempo}, \[3\*].
\:\\{term\_in}, \[81\*], 83.
\:\\{term\_out}, \[81\*], 82, 86, 87, 88, 89, 90.
\:\\{terminal\_line\_length}, \[5], 81\*, 83, 84.
\:\\{terse}, 77.
\:\\{text\_char}, \[9], 10.
\:\\{text\_file}, \[9].
\:\.{TFM file is bad}, 64.
\:\\{tfm\_check\_sum}, \[46], 65.
\:\\{tfm\_file}, \[24], 28\*, 33, 46, 65, 99.
\:\.{the file ended prematurely}, 130.
\:\\{the\_works}, 77.
\:\\{thirty\_seven\_cases}, \[6].
\:\\{thirty\_two\_cases}, \[6].
\:\\{three\_cases}, \[6].
\:\\{total\_glyphs}, \[55], 56, 71, 73.
\:\\{total\_pages}, \[122], 147.
\:\\{true}, 2, 28\*, 29\*, 35, 51, 58, 64, 71, 73, 76, 78, 80, 85, 87, 128,
137, 144.
\:\\{true\_conv}, \[61], 152.
\:\\{trunc}, 125.
\:\\{tty}, 3\*, 27, 28\*, 81\*.
\:\\{u\_byte}, 37.
\:\.{UNDEFINED}, 48.
\:\.{undefined command}, 132.
\:\\{undefined\_commands}, \[16], 52, 124.
\:\\{unity}, \[6].
\:\\{update\_terminal}, \[82], 83.
\:\|{v}, \[121].
\:\\{val}, 115, 116, 117, 118.
\:\\{verbose}, 77.
\:\\{vppp}, \[42], 52, \[55].
\:\\{vstack}, \[121], 133.
\:\\{vv}, \[121], 128, 133, 135, 138, 142.
\:\\{vvi}, \[121], 128, 138, 142.
\:\\{vvstack}, \[121], 133.
\:\\{vvv}, \[132], 142.
\:\|{w}, \[37], \[52], \[121].
\:\\{w\_byte}, \[46], 53, 54, 62.
\:\\{white}, 40.
\:\\{width}, 21, \[46], 61, 62, 66, 68, 92.
\:\\{width\_ptr}, \[46], 47, 58, 59, 62, 64, 65, 66, 68.
\:\\{wp}, \[58], 59, 62, \[64], 65, 66, 68.
\:\\{write}, 3\*, 28\*, 37, 87, 88, 89, 90.
\:\\{write\_ln}, 3\*, 86, 87, 88, 89, 90.
\:\\{wstack}, \[121], 133.
\:\\{w0}, 15, \[16], 124, 134.
\:\\{w1}, 15, \[16], 124, 134.
\:\\{w2}, 15.
\:\\{w3}, 15.
\:\\{w4}, 15.
\:\|{x}, \[17], \[85], \[121].
\:\\{xchr}, \[10], 11, 12, 48, 49, 102\*, 103\*.
\:\\{xord}, \[10], 12, 27, 83, 149\*.
\:\\{xstack}, \[121], 133.
\:\\{xxx1}, 15, \[16], 40, 52, 75, 76, 110, 124, 132.
\:\\{xxx2}, 15, \[40].
\:\\{xxx3}, 15, 40.
\:\\{xxx4}, 15, \[16], \[40].
\:\\{x0}, 15, \[16], 124, 134.
\:\\{x1}, 15, \[16], 124, 134.
\:\\{x2}, 15.
\:\\{x3}, 15.
\:\\{x4}, 15.
\:\|{y}, \[121].
\:\\{ystack}, \[121], 133.
\:\\{yyy}, 40, \[41], 43, 52, 75, 76.
\:\\{y0}, 15, \[16], 124, 135.
\:\\{y1}, 15, \[16], 124, 135.
\:\\{y2}, 15.
\:\\{y3}, 15.
\:\\{y4}, 15.
\:\|{z}, \[58], \[64], \[121].
\:\\{zstack}, \[121], 133.
\:\\{z0}, 15, \[16], 124, 135.
\:\\{z1}, 15, \[16], 124, 135.
\:\\{z2}, 15.
\:\\{z3}, 15.
\:\\{z4}, 15.
\fin
\:\X133:Cases for commands \\{nop}, \\{bop}, \dots, \\{pop}\X
\U section~131.
\:\X136:Cases for fonts\X
\U section~132.
\:\X134:Cases for horizontal motion\X
\U section~131.
\:\X135:Cases for vertical motion\X
\U section~132.
\:\X59:Check \\{width} table and \&{goto} 9997 if there is a problem\X
\U section~58.
\:\X53:Clear \\{w\_byte} array\X
\U section~52.
\:\X152:Compute the conversion factor\X
\U section~151.
\:\X5, 153\*:Constants in the outer block\X
\U section~3\*.
\:\X62:Convert and store the width values\X
\U section~58.
\:\X132:Declare the function called \\{special\_cases}\X
\U section~128.
\:\X88:Determine the desired \\{max\_pages}\X
\U section~86.
\:\X90:Determine the desired \\{new\_mag}\X
\U section~86.
\:\X89:Determine the desired \\{resolution}\X
\U section~86.
\:\X87:Determine the desired \\{start\_count} values\X
\U section~86.
\:\X146:Find the postamble then process the pages in reverse order\X
\U section~149\*.
\:\X144:Find the postamble, working back from the end\X
\U section~149\*.
\:\X143:Finish a command that changes the current font, then \&{goto} \\{done}\X
\U section~132.
\:\X139:Finish a command that either sets or puts a character, then \&{goto} %
\\{move\_right} or \\{done}\X
\U section~130.
\:\X140:Finish a command that either sets or puts a rule, then \&{goto} \\{move%
\_right} or \\{done}\X
\U section~130.
\:\X141:Finish a command that sets $\|h\K\|h+\|q$, then \&{goto} \\{done}\X
\U section~130.
\:\X142:Finish a command that sets $\|v\K\|v+\|p$, then \&{goto} \\{done}\X
\U section~132.
\:\X119:Get two paint commands\X
\U sections~116 and~116.
\:\X10, 24, 25, 30, 32, 46, 50, 55, 61, 77, 78, 81\*, 84, 92, 100\*, 111, 121,
122, 127, 145, 150, 155\*:Globals in the outer block\X
\U section~3\*.
\:\X4:Labels in the outer block\X
\U section~3\*.
\:\X102\*:Move font name into the \\{cur\_name} string\X
\U section~99.
\:\X103\*:Move font name into the \\{cur\_tfm\_name} string\X
\U section~99.
\:\X68:Move the widths from \\{in\_width} to \\{width}, and append \\{pixel%
\_width} values\X
\U section~64.
\:\X110:Pass over the raster details\X
\U section~106.
\:\X75:Pass \\{no\_op}, \\{xxx} and \\{yyy} commands\X
\U sections~69 and~106.
\:\X91:Print all the selected options\X
\U section~86.
\:\X54:Process the character locations in the postamble\X
\U section~52.
\:\X148:Process the font definitions of the postamble\X
\U section~147.
\:\X60:Process the gf preamble\X
\U section~58.
\:\X151:Process the preamble\X
\U section~149\*.
\:\X67:Read and convert the width values, setting up the \\{in\_width} table\X
\U section~64.
\:\X65:Read past the header data; \&{goto} 9997 if there is a problem\X
\U section~64.
\:\X96:Read the font parameters into position for font \\{nf}\X
\U section~95.
\:\X108:Read the \\{boc1} information\X
\U section~106.
\:\X107:Read the \\{boc} information\X
\U section~106.
\:\X63:Replace \|z by $\|z↑\prime$ and compute $\alpha,\beta$\X
\U sections~62 and~67.
\:\X106:Restow glyph rasters that have not been downloaded\X
\U section~104.
\:\X138:Resyncronize\X
\U sections~139, 139, and~140.
\:\X11, 12, 26, 47, 56, 79, 93, 101, 112, 123:Set initial values\X
\U section~3\*.
\:\X105:Skip over the preamble\X
\U section~104.
\:\X131:Start translation of command \|o and \&{goto} the appropriate label to
finish the job\X
\U section~130.
\:\X66:Store character-width indices at the end of the \\{width} table\X
\U section~64.
\:\X69:Stow all of the glyph-raster info\X
\U section~58.
\:\X76:Stow the glyph details\X
\U sections~69 and~106.
\:\X73:Stow the \\{boc1} information\X
\U section~69.
\:\X71:Stow the \\{boc} information\X
\U section~69.
\:\X109:Stow the \\{boc} or \\{boc1} information\X
\U section~106.
\:\X116:Translate a sequence of paint commands\X
\U section~115.
\:\X117:Translate a \\{new\_row} command\X
\U section~115.
\:\X118:Translate a \\{skip} command\X
\U section~115.
\:\X137:Translate an \\{xxx} command and \&{goto} \\{done}\X
\U section~132.
\:\X130:Translate the next command in the \.{DVI} file; \&{goto} 9999 if it was
\\{eop}\X
\U section~128.
\:\X8, 9, 23, 154\*:Types in the outer block\X
\U section~3\*.
\:\X97:Verify \\{font\_scaled\_size} and \\{font\_design\_size} for size\X
\U section~95.
\con